markosamuli / ansible-golang

Install Go programming language with Ansible

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

markosamuli.golang

GitHub release License pre-commit

Branch Status
master Build Status
develop Build Status

Ansible role to install Go programming language and development environment on Ubuntu and macOS.

Used for setting up my workstations in the following playbooks:

Go version

This role will install the Go version 1.15 from your package manager:

The role expects the package manager to provide minimum Go version 1.13.

Configuration

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

Development tools

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 Git hooks

Install pre-commit, pre-push and commit-msg Git hooks:

make install-git-hooks

Coding style

Install pre-commit hooks and validate coding style:

make lint

Run tests

Run tests in Ubuntu and Debian using Docker:

make test

License

MIT

Author Information

About

Install Go programming language with Ansible

License:MIT License


Languages

Language:Shell 86.8%Language:Makefile 11.6%Language:JavaScript 1.6%