Skip to content

Commit

Permalink
Moarfix (#24)
Browse files Browse the repository at this point in the history
* bunch of fixes to make all tests pass

* Jaana is right, as always
  • Loading branch information
campoy authored Jul 6, 2017
1 parent 0adedc4 commit 33ac441
Show file tree
Hide file tree
Showing 41 changed files with 166 additions and 56 deletions.
2 changes: 0 additions & 2 deletions 1-source-code/1-workspace/hello-vendor/.gitignore

This file was deleted.

4 changes: 2 additions & 2 deletions 1-source-code/2-writing/1-editors-and-plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ instead your editor will call it.

### Exercise: code completion

Open [hello.go](hello.go) with VSCode, you should see this content:
Open [hello/main.go](hello/main.go) with VSCode, you should see this content:

[embedmd]:# (hello.go /package main/ $)
[embedmd]:# (hello/main.go /package main/ $)
```go
package main

Expand Down
12 changes: 6 additions & 6 deletions 1-source-code/2-writing/2-gofmt-and-friends.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ these fixes were more common while the language was still actively changing.
`gorename` provides renaming of identifiers in a type safe way across files and even packages.
Given the following code in [torename.go](torename.go):
Given the following code in [torename/main.go](torename/main.go):
[embedmd]:# (torename.go /package main/ $)
[embedmd]:# (torename/main.go /package main/ $)
```go
package main
Expand All @@ -199,7 +199,7 @@ func doStuff(name string) {
You can rename `doStuff` to a more appropriate name directly from your console:
```bash
$ gorename -from torename.go::doStuff -to greet
$ gorename -from torename/main.go::doStuff -to greet
Renamed 2 occurrences in 1 file in 1 package.
```
Expand All @@ -217,9 +217,9 @@ quick result.
Some packages in the standard library, such as `encoding/json` and `encoding/xml`,
use struct field tags as a way to provide information on how a struct should
be encoded. For instance given the code in [tags.go](tags.go):
be encoded. For instance given the code in [tags/main.go](tags/main.go):
[embedmd]:# (tags.go /package main/ $)
[embedmd]:# (tags/main.go /package main/ $)
```go
package main
Expand Down Expand Up @@ -255,7 +255,7 @@ You can make `Name` and `Age` appear as `name` and `age` in the JSON output by
running `gomodifytags`:
```bash
$ gomodifytags -file tags.go -add-tags json -struct Person
$ gomodifytags -file tags/main.go -add-tags json -struct Person
package main
import (
Expand Down
6 changes: 3 additions & 3 deletions 1-source-code/2-writing/3-vet-and-lint.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ As for editing, many tools have been created that can be used to analyze your co
early on and detect mistakes. We will cover just one more, one that will detect
what the problem is with the following code.

[embedmd]:# (errcheck.go /package main/ $)
[embedmd]:# (errcheck/main.go /package main/ $)
```go
package main

Expand Down Expand Up @@ -202,8 +202,8 @@ $ go get github.com/kisielk/errcheck
Then run it on any Go file you'd like to verify:

```bash
$ errcheck errcheck.go
errcheck.go:24:21: http.ListenAndServe(":80", nil)
$ errcheck errcheck/main.go
errcheck/main.go:24:21: http.ListenAndServe(":80", nil)
```

As you can see this linter is pretty slow, so it is not recommended to have it
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion 2-building-artifacts/1-go-build.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,4 @@ You're now an expert on ... basic compilation of Go programs. But you're already
to cross-compile Go programs to other platforms!

Next, let's talk about how to better understand the behavior of running programs in
the [dynamic analysis section](../3-dynamic-analysis/README.md).
the [dynamic analysis section](../3-dynamic-analysis/README.md).
2 changes: 1 addition & 1 deletion 2-building-artifacts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ We will also cover some cool techniques to embed assets into our static
binaries to simplify deployment.

There's a lot of material to cover in this section, so let's get
started with the [first chapter](1-go-build.md) and learn how to compile a simple Go program.
started with the [first chapter](1-go-build.md) and learn how to compile a simple Go program.
5 changes: 4 additions & 1 deletion 2-building-artifacts/exercise/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ package main

import "fmt"

// HINT: You might need to move this declaration to a different file.
const version = "development"

func main() {
fmt.Println("running %s version", version)
fmt.Printf("running %s version", version)
}
12 changes: 7 additions & 5 deletions 3-dynamic-analysis/2-testing/1-go-test.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ package sum
import "testing"

func TestRecursive(t *testing.T) {
t.Fatalf("test not implemented")
// Implement the body of this test, calling recursive.
}
```

Expand All @@ -100,7 +100,7 @@ package sum_test
import "testing"

func TestAll(t *testing.T) {
t.Fatalf("test not implemented")
// Implement the body of this test, calling sum.All.
}
```

Expand Down Expand Up @@ -187,16 +187,18 @@ TestIndex_Subtest(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
if idx := strings.Index(tc.text, tc.sub); idx != tc.idx {
if tc.idx >= 0 {
t.Errorf("%s should contain %s at position %d, not %d", tc.text, tc.sub, tc.idx, idx)
} else {
t.Errorf("%s should not contain %s", tc.text, tc.sub)
t.Fatalf("%s should contain %s at position %d, not %d", tc.text, tc.sub, tc.idx, idx)
}
t.Fatalf("%s should not contain %s", tc.text, tc.sub)
}
})
}
}
```

_Note_: you can use `Fatalf` with subtests and only the current subtest will fail, unlike in the
previous loops where later tests would be ignored.

If you run `go test -v` you'll see the subtest that were ran.

```bash
Expand Down
2 changes: 1 addition & 1 deletion 3-dynamic-analysis/2-testing/3-continuous-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ to contribute the content of this page I definitely accept Pull Requests!
## Congratulations

Yeah, I know. This page is empty. But please continue this workshop.
We will discuss performance analysis with the [next chapter](../3-profiling/1-benchmarks.md).
We will discuss performance analysis with the [next chapter](../3-profiling/1-benchmarks.md).
5 changes: 2 additions & 3 deletions 3-dynamic-analysis/2-testing/strings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,9 @@ func TestIndex_Subtest(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
if idx := strings.Index(tc.text, tc.sub); idx != tc.idx {
if tc.idx >= 0 {
t.Errorf("%s should contain %s at position %d, not %d", tc.text, tc.sub, tc.idx, idx)
} else {
t.Errorf("%s should not contain %s", tc.text, tc.sub)
t.Fatalf("%s should contain %s at position %d, not %d", tc.text, tc.sub, tc.idx, idx)
}
t.Fatalf("%s should not contain %s", tc.text, tc.sub)
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion 3-dynamic-analysis/2-testing/sum/sum_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ package sum
import "testing"

func TestRecursive(t *testing.T) {
t.Fatalf("test not implemented")
// Implement the body of this test, calling recursive.
}
2 changes: 1 addition & 1 deletion 3-dynamic-analysis/2-testing/sum/sum_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ package sum_test
import "testing"

func TestAll(t *testing.T) {
t.Fatalf("test not implemented")
// Implement the body of this test, calling sum.All.
}
8 changes: 4 additions & 4 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
required = ["github.com/golang/example/hello"]
required = ["github.com/golang/example/hello"]

[[constraint]]
branch = "master"
name = "github.com/Sirupsen/logrus"
1 change: 1 addition & 0 deletions congratulations.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ questions too.
I hope you enjoyed it as much as I did writing it, and I hope you learned a ton.

![fancy gopher](fancygopher.jpg)
The Go gopher is a creation by Renee French.
1 change: 0 additions & 1 deletion vendor/github.com/Sirupsen/logrus/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 12 additions & 10 deletions vendor/github.com/Sirupsen/logrus/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/golang.org/x/sys/unix/mkerrors.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions vendor/golang.org/x/sys/unix/syscall_linux.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/golang.org/x/sys/unix/zerrors_linux_386.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/golang.org/x/sys/unix/zerrors_linux_arm.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/golang.org/x/sys/unix/zerrors_linux_mips.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion vendor/golang.org/x/sys/windows/dll_windows.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 33ac441

Please sign in to comment.