├── .gitignore ├── exercise_solutions ├── ex2 │ ├── go.mod │ ├── hello.go │ ├── Makefile │ └── README.md └── ex1 │ └── README.md ├── sample_code ├── hello_world │ ├── go.mod │ ├── hello.go │ └── Makefile └── hello_world_vet │ ├── go.mod │ ├── hello.go │ └── Makefile └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .vscode 3 | *.iml 4 | .DS_Store 5 | -------------------------------------------------------------------------------- /exercise_solutions/ex2/go.mod: -------------------------------------------------------------------------------- 1 | module hello_world 2 | 3 | go 1.19 4 | -------------------------------------------------------------------------------- /sample_code/hello_world/go.mod: -------------------------------------------------------------------------------- 1 | module hello_world 2 | 3 | go 1.18 4 | -------------------------------------------------------------------------------- /sample_code/hello_world_vet/go.mod: -------------------------------------------------------------------------------- 1 | module hello_world 2 | 3 | go 1.18 4 | -------------------------------------------------------------------------------- /exercise_solutions/ex2/hello.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | fmt.Println("Hello, world!") 7 | } 8 | -------------------------------------------------------------------------------- /sample_code/hello_world/hello.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | fmt.Println("Hello, world") 7 | } 8 | -------------------------------------------------------------------------------- /sample_code/hello_world_vet/hello.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | fmt.Printf("Hello, %s\n") 7 | } 8 | -------------------------------------------------------------------------------- /exercise_solutions/ex2/Makefile: -------------------------------------------------------------------------------- 1 | .DEFAULT_GOAL := build 2 | 3 | .PHONY:fmt vet build 4 | fmt: 5 | go fmt ./... 6 | 7 | vet: fmt 8 | go vet ./... 9 | 10 | build: vet 11 | go build 12 | 13 | clean: 14 | go clean 15 | 16 | 17 | -------------------------------------------------------------------------------- /sample_code/hello_world/Makefile: -------------------------------------------------------------------------------- 1 | .DEFAULT_GOAL := build 2 | 3 | .PHONY: fmt vet build clean 4 | fmt: 5 | go fmt ./... 6 | 7 | vet: fmt 8 | go vet ./... 9 | 10 | build: vet 11 | go build 12 | 13 | clean: 14 | go clean 15 | 16 | -------------------------------------------------------------------------------- /sample_code/hello_world_vet/Makefile: -------------------------------------------------------------------------------- 1 | .DEFAULT_GOAL := build 2 | 3 | .PHONY: fmt vet build clean 4 | fmt: 5 | go fmt ./... 6 | 7 | vet: fmt 8 | go vet ./... 9 | 10 | build: vet 11 | go build 12 | 13 | clean: 14 | go clean 15 | 16 | -------------------------------------------------------------------------------- /exercise_solutions/ex1/README.md: -------------------------------------------------------------------------------- 1 | # Exercise 1 2 | 3 | ## Question 4 | Take our "Hello, world!" program and run it on the Go Playground. Share a link to the code in the playground with a co-worker who would love to learn about Go. 5 | 6 | ## Solution 7 | 8 | You should have a URL with content like this: https://go.dev/play/p/Znr6hsgvdlB -------------------------------------------------------------------------------- /exercise_solutions/ex2/README.md: -------------------------------------------------------------------------------- 1 | # Exercise 2 2 | 3 | ## Question 4 | 5 | Add a target to the Makefile called `clean` that removes the `hello_world` binary and any other temporary files created by `go build`. Take a look at the [Go command documentation](https://pkg.go.dev/cmd/go) to find a `go` command to help implement this. 6 | 7 | ## Solution 8 | 9 | See `Makefile` in this directory. 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 learning-go-book-2e 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | --------------------------------------------------------------------------------