Skip to content

Commit

Permalink
Merge branch 'stringers' of https://github.com/norbs57/go into stringers
Browse files Browse the repository at this point in the history
  • Loading branch information
norbs57 committed Apr 30, 2022
2 parents 7538af2 + 842f6c0 commit bdb30da
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
9 changes: 9 additions & 0 deletions docs/TESTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ $ cd exercism/project/directory/go/leap
$ go test
```

# Tests with Data Race Detector

In addition to running `go test`, some exercises should be run with a flag for [data race detector](https://go.dev/doc/articles/race_detector) to check that your solution does not introduce data race bugs. You will find a reminder to run tests with the data race detector flag `-race` in the relevant exercises. Run `go test -race` to check for data race. For example:

```bash
$ cd exercism/project/directory/go/bank-account
$ go test -race
```

## Running benchmarks

Most exercises contain benchmarks, that you can use to determine how changes to your solution affect its performance. To run the benchmarks for an exercise use the command `go test -v --bench . --benchmem` inside the exercise directory.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ In this exercise you'll be working with savings accounts.
Each year, the balance of your savings account is updated based on its interest rate.
The interest rate your bank gives you depends on the amount of money in your account (its balance):

- 3.213% for a negative balance (balance gets more negative).
- 0.5% for a positive balance less than `1000` dollars.
- 1.621% for a positive balance greater or equal than `1000` dollars and less than `5000` dollars.
- 2.475% for a positive balance greater or equal than `5000` dollars.
- 3.213% for a balance less than `0` dollars (balance gets more negative).
- 0.5% for a balance greater than or equal to `0` dollars, and less than `1000` dollars.
- 1.621% for a balance greater than or equal to `1000` dollars, and less than `5000` dollars.
- 2.475% for a balance greater than or equal to `5000` dollars.

You have four tasks, each of which will deal your balance and its interest rate.

Expand Down
8 changes: 8 additions & 0 deletions exercises/practice/bank-account/.docs/instructions.append.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ For example: multiple goroutines may be depositing and withdrawing money
simultaneously, two withdrawals occurring concurrently should not be able
to bring the balance into the negative.

When working locally, you can test that your code handles concurrency properly and does not introduce
data races, run tests with `-race` flag on.

```bash
$ cd exercism/project/directory/go/bank-account
$ go test -race
```

If you are new to concurrent operations in Go it will be worth looking
at the sync package, specifically Mutexes:

Expand Down

0 comments on commit bdb30da

Please sign in to comment.