golang-cli-template
An opinionated template for new Golang cli projects.
It includes:
- The base of a cli using
spf13/cobra
(including the version
command)
- Everything needed to test using
stretchr/testify
- The optimized and secured Dockerfile
- Templating engine using
rantav/go-archetype
- Basic GitHub actions
- Release management using
goreleaser/goreleaser
:
- Generate the completions scripts
- Generate the man pages
- Push images for
homebrew
, apt
, yum
and apk
- Generate the
.rpm
, .deb
and .apk
package files
Init your own project using that template
We are using rantav/go-archetype to enable the creation of new projects from that template.
$ go install github.com/rantav/go-archetype@latest
$ go-archetype transform --transformations .go-archetype.yaml --source . --destination /path/to/destination
# answer the questions
$ cd /path/to/destination
# init your git repository and you're done.
As you may have notices the LICENSE
file is missing. Please add the according Licence file. You can find most of the licenses here.
Enjoy developing your awesome cli.
Install
homebrew tap
brew install thazelart/tap/golang-cli-template
apt
echo 'deb [trusted=yes] https://apt.fury.io/thazelart/ /' | sudo tee /etc/apt/sources.list.d/thazelart.list
sudo apt update
sudo apt install golang-cli-template
yum
echo '[thazelart]
name=Gemfury thazelart repository
baseurl=https://yum.fury.io/thazelart/
enabled=1
gpgcheck=0' | sudo tee /etc/yum.repos.d/thazelart.repo
sudo yum install goreleaser
deb, rpm and apk packages
Download the .deb, .rpm or .apk packages from the [release page](https://github.com/thazelart/golang-cli-template/releases) and install them with the appropriate tools.
go install
go install github.com/thazelart/golang-cli-template@latest
from the GitHub releases
Download the pre-compiled binaries from the release page page and copy them to the desired location.
$ VERSION=v1.0.0
$ OS=Linux
$ ARCH=x86_64
$ TAR_FILE=golang-cli-template_${OS}_${ARCH}.tar.gz
$ wget https://github.com/thazelart/golang-cli-template/releases/download/${VERSION}/${TAR_FILE}
$ sudo tar xvf ${TAR_FILE} golang-cli-template -C /usr/local/bin
$ rm -f ${TAR_FILE}
manually
$ git clone github.com/thazelart/golang-cli-template
$ cd golang-cli-template
$ go generate ./...
$ go install
Logo
This logo is based on the create-go-app
logo. Please find all information here.