Skip to content
Source code, notes and useful commands created / used while learning Go
Go JavaScript HTML
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Learning Go - notes and useful commands

Download sources from GitHub

go get

Format source code

go fmt

Verify source code

go vet

Build go program

go build

go build -o {nazwa}

Remove binary

go clean

Build and run program

go run <FILENAME>.go

Test program

go test

Test coverage

go test -cover

Set GOPATH on macOS / Linux

vi .bash_profile

export GOPATH=$HOME/go

source .bash_profile

Generate documentation and share it via HTTP server

godoc -http=:6060

Use goimports for updating import lines

goimports is adding missing ones and removing unreferenced ones. It can be installed using commands:

go get

After installing goimports we have to modify $PATH variable:

vi .bash_profile


To update all files in current directory following command should be used:

goimports -w .

You can’t perform that action at this time.