Skip to content

Boilerplate to kickstart creating a Go command-line tool.

License

Notifications You must be signed in to change notification settings

johnsonshi/go-cli-boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-cli-boilerplate

Boilerplate to kickstart creating a Go command-line tool.

Getting Started

Cloning the Repo

Click the "Use this template" button.

Alternatively, create a new directory and clone the repo:

mkdir new-directory
cd new-directory
curl -fsSL https://github.com/johnsonshi/go-cli-boilerplate/archive/main.tar.gz | tar -xz --strip-components=1

Initialize Go Modules

Initialize go.mod and go.sum.

Note: Replace <your-github-username> and <your-github-repo-name> before running the following command:

rm go.mod go.sum
go mod init github.com/<your-github-username>/<your-github-repo-name>
go mod tidy

Initialize Git

git init
git add -A
git status
git commit -s -m "Initial commit"

Building and Running the CLI Locally

Build the command-line tool with the make command using the Makefile. This builds an executable binary at ./bin/command.

make build-cli

To run the command-line tool:

./bin/command

Modifying the CLI

The command-line tool can be modified to suit your needs through changes to ./cmd/cli/root.go and ./cmd/cli/subcommand.go.

GitHub Actions Workflows

There are several GitHub Actions Workflows under the .github/workflows directory.

These should kickstart builds and releases for your Go command-line tool.

Build Workflow

.github/workflows/build.yml

Builds the command-line tool on each push to the main branch.

Release Workflow

.github/workflows/release.yml

New Releases Through Pushing Git Tags

When a git tag with the format v* is pushed, the release workflow builds the command-line tool and creates a GitHub release.

E.g. A GitHub release is created when the tag v1.2.5 is pushed (conforms to the git tag format v*).

New Pre-Releases Through Pushing Git Tags

When a git tag containing -alpha., -beta., -rc., or -nightly. is pushed, a GitHub pre-release is created instead. GitHub will point out that this release is identified as non-production ready.

About

Boilerplate to kickstart creating a Go command-line tool.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published