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: command-line.md
+7-7
Original file line number
Diff line number
Diff line change
@@ -68,7 +68,7 @@ Finally, we need to import this package into `main.go` so we can use it to creat
68
68
The paths will be different on your computer, but it should be similar to this:
69
69
70
70
```go
71
-
//cmd/webserver/main.go
71
+
//cmd/webserver/main.go
72
72
package main
73
73
74
74
import (
@@ -116,7 +116,7 @@ In addition, users can view [the documentation at pkg.go.dev](https://pkg.go.dev
116
116
Before we get stuck into writing tests, let's add a new application that our project will build. Create another directory inside `cmd` called `cli` (command line interface) and add a `main.go` with the following
117
117
118
118
```go
119
-
//cmd/cli/main.go
119
+
//cmd/cli/main.go
120
120
package main
121
121
122
122
import"fmt"
@@ -137,7 +137,7 @@ Before we jump too far ahead though, let's just write a test to check it integra
137
137
Inside `CLI_test.go` (in the root of the project, not inside `cmd`)
138
138
139
139
```go
140
-
//CLI_test.go
140
+
//CLI_test.go
141
141
package poker
142
142
143
143
import"testing"
@@ -172,7 +172,7 @@ At this point, you should be comfortable enough to create our new `CLI` struct w
172
172
You should end up with code like this
173
173
174
174
```go
175
-
//CLI.go
175
+
//CLI.go
176
176
package poker
177
177
178
178
typeCLIstruct {
@@ -464,7 +464,7 @@ Anecdotally I have used this technique in other shared packages and it has prove
464
464
So let's create a file called `testing.go` and add our stub and our helpers.
465
465
466
466
```go
467
-
//testing.go
467
+
//testing.go
468
468
package poker
469
469
470
470
import"testing"
@@ -622,7 +622,7 @@ Now refactor both of our applications to use this function to create the store.
Copy file name to clipboardExpand all lines: hello-world.md
+15-15
Original file line number
Diff line number
Diff line change
@@ -409,20 +409,20 @@ The tests should now pass.
409
409
Now it is time to _refactor_. You should see some problems in the code, "magic" strings, some of which are repeated. Try and refactor it yourself, with every change make sure you re-run the tests to make sure your refactoring isn't breaking anything.
410
410
411
411
```go
412
-
const spanish = "Spanish"
413
-
const englishHelloPrefix = "Hello, "
414
-
const spanishHelloPrefix = "Hola, "
412
+
const spanish = "Spanish"
413
+
const englishHelloPrefix = "Hello, "
414
+
const spanishHelloPrefix = "Hola, "
415
415
416
-
funcHello(namestring, languagestring) string {
417
-
if name == "" {
418
-
name = "World"
419
-
}
416
+
funcHello(namestring, languagestring) string {
417
+
if name == "" {
418
+
name = "World"
419
+
}
420
420
421
-
if language == spanish {
422
-
return spanishHelloPrefix + name
421
+
if language == spanish {
422
+
return spanishHelloPrefix + name
423
+
}
424
+
return englishHelloPrefix + name
423
425
}
424
-
return englishHelloPrefix + name
425
-
}
426
426
```
427
427
428
428
### French
@@ -483,10 +483,10 @@ You could argue that maybe our function is getting a little big. The simplest re
Copy file name to clipboardExpand all lines: io.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -718,7 +718,7 @@ store := &FileSystemPlayerStore{database}
718
718
If you run the test it should pass and now we can delete `InMemoryPlayerStore`. `main.go` will now have compilation problems which will motivate us to now use our new store in the "real" code.
719
719
720
720
```go
721
-
//main.go
721
+
//main.go
722
722
package main
723
723
724
724
import (
@@ -822,7 +822,7 @@ How will we test for this though? What we need to do is first refactor our code
822
822
We'll create a new type to encapsulate our "when we write we go from the beginning" functionality. I'm going to call it `Tape`. Create a new file with the following:
0 commit comments