You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: iteration.md
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
**[You can find all the code for this chapter here](https://github.com/quii/learn-go-with-tests/tree/master/for)**
4
4
5
-
To do stuff repeatedly in Go, you'll need `for`. In go there are no `while`, `do`, `until` keywords, you can only use `for`. Which is a good thing!
5
+
To do stuff repeatedly in Go, you'll need `for`. In Go there are no `while`, `do`, `until` keywords, you can only use `for`. Which is a good thing!
6
6
7
7
Let's write a test for a function that repeats a character 5 times.
8
8
@@ -38,7 +38,7 @@ All you need to do right now is enough to make it compile so you can check your
38
38
```go
39
39
package iteration
40
40
41
-
funcRepeat(characterstring) string{
41
+
funcRepeat(characterstring) string {
42
42
return""
43
43
}
44
44
```
@@ -103,7 +103,7 @@ The `testing.B` gives you access to the cryptically named `b.N`.
103
103
104
104
When the benchmark is run the code is ran `b.N` times, and measures how long it takes.
105
105
106
-
The amount of times the code is ran shouldnt matter to you, the framework will determine what is a "good" value for that to let you have some decent results.
106
+
The amount of times the code is ran shouldn't matter to you, the framework will determine what is a "good" value for that to let you have some decent results.
107
107
108
108
To run the benchmarks do `go test -bench=.`
109
109
@@ -123,10 +123,10 @@ _NOTE_ by default Benchmarks are run sequentially.
123
123
124
124
* Change the test so a caller can specify how many times the character is repeated and then fix the code
125
125
* Write `ExampleRepeat` to document your function
126
-
* Have a look through the [the strings package](https://golang.org/pkg/strings) package. Find functions you think could be useful and experiment with them by writing tests like we have here. Investing time learning the standard library will really pay off over time.
126
+
* Have a look through the [the strings](https://golang.org/pkg/strings) package. Find functions you think could be useful and experiment with them by writing tests like we have here. Investing time learning the standard library will really pay off over time.
0 commit comments