Experiments on Go
Go is an open source programming language. To install it, you can either download it from golang.org or use brew:
brew install golang
...
go version
>> go version go1.11.2 darwin/amd64
Run you script hello.go
with:
go run src/examples/hello.go
>> Hello, World!
Install it in your $GOPATH/bin
with:
go install hello.go
You need to set your own $GOPATH
for it to work.
Check setup.sh
to see which path to export, Add the change to your .bashrc
to make it permanent.
Run the following command to create a new module:
go mod init <module-name>
This will create a go.mod
file in the current directory.
To add a dependency, run:
go get <package-name>
This will add the package to the go.mod
file.
To install all dependencies, and clean up the go.mod
file, run:
go mod tidy
You can also use go mod download
which will download all dependencies in the cache.
Run unit tests:
go test ./...
This should run all the tests in the current directory and subdirectories.
Here are a couple of useful links: