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.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
chat
trace
.gitignore
LICENSE
README.md
hello.go

README.md

Learning Go - notes and useful commands

Download sources from GitHub

go get github.com/matryer/goblueprints

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 golang.org/x/tools/cmd/goimports

After installing goimports we have to modify $PATH variable:

vi .bash_profile

...
PATH="/Users/seba/go/bin:${PATH}"
...

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

goimports -w .

You can’t perform that action at this time.