for
func
can return 0 - n values, common a value and an err_
)1 This presentation is build with Hugo and the reveal.js theme reveal-hugo
Simple types linke string
, int
, bool
, array
, slice
Complex types and it’s functions like net.IP
, time.Duration
Collection of fields (struct
) like url.URL
Explicit conversion between types required!
# module maintenance
go mod
# initialize new module in current directory
go mod init github.com/t3easy/hello-go
# add missing and remove unused modules
go mod tidy
# add dependencies to current module and install them
go get github.com/spf13/cobra@latest
# test packages
go test ./...
# compile packages and dependencies
go build
# update dependencies
go get -u ./...
# update with test dependencies
go get -t -u ./...
Every Go program is made up of packages.
Programs start running in package main
.
Standard lib, internal and external packages must be imported.
Every module has a name, preferable the repo url
go mod init github.com/t3easy/hello-go
go.mod
- Module name, Go version and dependenciescomposer.json
go.sum
- Checksum of direct and indirect dependenciescomposer.lock
brew install go