Go Tools

Maximilian Wurzer

Advisory IT Architect, IBM Deutschland

The 'go' utility (1/3)

Compiler, package-manager, formatter, linter, ... all in a single tool:


        bug         start a bug report
        build       compile packages and dependencies
        clean       remove object files and cached files
        doc         show documentation for package or symbol
        env         print Go environment information
        fix         update packages to use new APIs
        fmt         gofmt (reformat) package sources
        generate    generate Go files by processing source
        get         add dependencies to current module and install them
        install     compile and install packages and dependencies
        list        list packages or modules
        mod         module maintenance
        run         compile and run Go program
        test        test packages
        tool        run specified go tool
        version     print Go version
        vet         report likely mistakes in packages
2

The 'go' utility (2/3)

go run: Compile and run a program ad-hoc

go build: Compile or cross-compile program

go test: Run tests

go get: Download a dependency of a module and install them

3

The 'go' utility (3/3)

go doc: Get the docs for a method

package http // import "net/http"

func ListenAndServe(addr string, handler Handler) error
    ListenAndServe listens on the TCP network address addr and then calls Serve
    with handler to handle requests on incoming connections. Accepted
    connections are configured to enable TCP keep-alives.

    The handler is typically nil, in which case the DefaultServeMux is used.

    ListenAndServe always returns a non-nil error.

go mod: Interact with modules

4

Go-Playground

5

Package-Management - Go has a unique approach to package management

6

Package-Management - Modules

module example.com/my/thing

go 1.12

require example.com/other/thing v1.0.2
require example.com/new/thing/v2 v2.3.4
exclude example.com/old/thing v1.2.3
replace example.com/bad/thing v1.4.5 => example.com/good/thing v1.4.5
7

Online resources

8

Thank you

Maximilian Wurzer

Advisory IT Architect, IBM Deutschland

Use the left and right arrow keys or click the left and right edges of the page to navigate between slides.
(Press 'H' or navigate to hide this message.)