Branch | Status |
---|---|
master | |
develop |
Ansible role to install Go programming language and development environment on Ubuntu and macOS.
Used for setting up my workstations in the following playbooks:
This role will install the Go version 1.15 from your package manager:
[email protected]
Homebrew Formula on macOSgolang-1.15
package from golang-backports PPA on Ubuntu
The role expects the package manager to provide minimum Go version 1.13.
To change Go version to 1.12:
golang_version: "1.12"
Configure GOPATH
for Go projects:
golang_path: "go"
The path is relative to the current user home directory, for
example golang_path: "Projects/go"
will become ~/Projects/go
.
Update GOPATH
and PATH
in .bashrc
and .zshrc
:
golang_init_shell: true
You should disable golang_init_shell
if you're managing your shell
scripts using .dotfiles
and don't want to mess up them.
To use Go modules with GO111MODULES=auto
:
golang_modules: true
The following development tools are installed:
- golint is a linter for Go source code
- goimports is a tool for updating your Go import lines
- errcheck is a program for checking for unchecked errors in go programs
- go-callvis is a development tool to help visualize call graph of a Go program using interactive view
- gopkgs is a tool that provides list of available Go packages that can be imported
- Stringer is a tool to automate the creation of methods that satisfy the fmt.Stringer interface
- guru is a tool for answering questions about Go source code
- staticcheck is a linter for Go source code
To add or remove installed packages, update the list in golang_packages
:
golang_packages:
- name: github.com/kisielk/errcheck
- name: github.com/TrueFurby/go-callvis
- name: golang.org/x/lint
- name: golang.org/x/tools/cmd/goimports
- name: golang.org/x/tools/cmd/stringer
- name: golang.org/x/tools/cmd/guru
- name: honnef.co/go/tools/cmd/staticcheck
- name: github.com/uudashr/gopkgs@v2
Above packages will be installed with GO111MODULES=on
set.
Make sure Git is installed if installing packages or the role will fail.
Install pre-commit
, pre-push
and commit-msg
Git hooks:
make install-git-hooks
Install pre-commit hooks and validate coding style:
make lint
Run tests in Ubuntu and Debian using Docker:
make test