Go apps 101: how to build & test them

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.

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

GoLab is a conference made by Develer.
Develer is a company based in Campi Bisenzio, near Florence. Our motto is : "Technology to give life to your products". We produce hardware and software to create exceptional products and to improve industrial processes and people's well being.
In Develer we have passion for the new technologies and we offer our clients effective solutions that are also efficient, simple and safe for the end users. We also believe in a friendly and welcoming environment where anybody can give their contribution. This passion and this vision are what we've been driven to organize our conference "made by developers for developers".


Subscribe to our newsletter

We hate spam just as much as you do, which is why we promise to only send you relevant communications. We respect your privacy and will never share your information with third parties.
©2024 GoLab | The international conference on Go in Florence-Design & devCantiere Creativo-Made withDatoCMS