Go

Installation

brew install go

New Project

projectName=$(basename $(pwd))
go mod init github.com/cfclrk/$projectName
go mod tidy

Cobra

Create a new cobra project:

projectName=$(basename $(pwd))
cobra init --pkg-name github.com/cfclrk/$projectName
rm LICENSE

# Remove all block comments (between /* and */) in each file
sed -i "" '/\/\*/,/\*\//d' main.go
sed -i "" '/\/\*/,/\*\//d' cmd/root.go

go mod init github.com/cfclrk/$projectName
go mod tidy
#+RESULTS:
Your Cobra applicaton is ready at
/Users/chris.clark/Projects/use

Docker

Run golang container for interactive use:

docker run -it --rm golang:1.16

Mount current project in container:

docker run -it --rm \
       --mount type=bind,source=(pwd),target=/root/$(basename $(pwd)) \
       golang:1.16