It is highly recommended to use GoLand from JetBrains for development. If you are a student, you can use GoLand for free with an educational licence.
- Install go locally or let GoLand install for you
- Sync dependencies (this can likely be done if you simply
go build
, or simply let GoLand install for you) - Build, test, code, and repeat
On a Linux/macOS machine, you should be able to use make
command to build, test, and package the repository.
Install cobra dependencies: (required to generate new commands)
go install github.com/spf13/cobra/[email protected]
Add new cobra command
# add new subcommand
cobra add <child command> -p <parent command>
cobra add childCommand -p 'parentCommand'
Add or adjust ~/.cobra.yaml
file for your name, license, year, etc. See CLI usage in the docs for details.
Go Module:
# you don't have to run this since we already have a go.mod and go.sum file
go mod init github.com/<name>/<repo-name>
# add new library
go get <new dependency>
# organize modules and dependencies
go mod tidy
# remove dependency
go mod edit -dropreplace github.com/go-chi/chi
When writing instructions in the CLI and in the README, please follow syntax recommended by google developer docs
Change package name:
# change module name in all files
find . -type f \( -name '*.go' -o -name '*.mod' \) -exec sed -i -e "s;container-helper;ch;g" {} +
Note: This is mainly a reminder for me since I can't remember how on Earth to git tag stuff sometimes!
# releasing a new version
git tag -a v1.4 -m "Version notes here"
To delete tagging mistakes locally:
# delete local tag
git tag -d tagname
To delete remote tags:
# delete a tag already pushed to github
git push --delete origin tagname