Skip to content

FalcoSuessgott/golang-cli-template

Repository files navigation

golang-cli-template

A general purpose project template for golang CLI applications

Test golangci-lint Go Report Card Go Reference codecov

This template serves as a starting point for golang commandline applications based on the go community default project-layout.

Features

  • goreleaser with deb. and .rpm package releasing
  • golangci-lint for linting and formatting
  • Golang Github Actions Stages (Linting, Testing, Releasing)
  • Gitlab CI Configuration (Linting, Testing, Releasing)
  • tested cobra setup
  • Makefile - with various useful targets (see Makefile Targets)

Project Layout

  • assets/ => docs, images, etc
  • cmd/ => commandline configurartions (flags, subcommands)
  • pkg/ => packages that are okay to import for other projects
  • internal/ => packages that are only for project internal purposes

Demo Application

$> golang-cli-template                                                  
golang-cli project template demo application

Usage:
  golang-cli-template [flags]
  golang-cli-template [command]

Available Commands:
  example     example subcommand which adds or multiplies two given integers
  help        Help about any command
  version     Displays d4sva binary version

Flags:
  -h, --help   help for golang-cli-template

Use "golang-cli-template [command] --help" for more information about a command.
$> golang-cli-template 2 5 --add                                                
7

$> golang-cli-template 2 5 --multiply
10

Makefile Targets

lint

make lint

format

make fmt

formatcheck

make fmtcheck

build

make build

test

make test

cover

make cover