Abstract
This talk is a fundamental exploration of Go app basics: best practices to building internal services, meaningful return types, error handling, isolation of external dependencies and unit testing design. It will give Go beginners a good starting point to building testable and well designed apps. The main goal of the talk will be to produce a small working example of an internal service that can then be exposed as a public interface. The example will be progressively built up, while pointing out design & testing best practices that can help Go beginners build idiomatic Go apps. It will present some of the Go principles such as favouring returning structs, handling errors first and defining small interfaces in the caller code, as the Go proverb “accept interfaces but return structs” goes.
Setup
Go setup Download & install the Go tools. Make sure you add the bin directory to your PATH as well. Choose the installation steps for your OS at golang.org You will need to install Go 1.12 or newer to run this code. The default workspace directory is $HOME/go. If you'd like to use a different directory, you will need to setup your GOPATH environment variable. Set an environment variable $GO111MODULE=on. This is only required for Go versions of 1.11 & 1.12, as 1.13 has this enabled by default. Test your installation easily. Create a new file main.go in your GOPATH and add the code below to it. package main import "fmt" func main() { fmt.Printf("All set and ready to Go! ") } Run your code with the command below and make sure you see the output All set and ready to Go!. $ go run main.go Repo setup Clone this repo into $GOPATH/src/github.com directory. For further info please check: https://github.com/addetz/go_apps_101#setup