Categorygithub.com/wdstar/go-cmd-example
modulepackage
0.2.0
Repository: https://github.com/wdstar/go-cmd-example.git
Documentation: pkg.go.dev

# README

go-cmd-example

Golang CLI implementation example

Development

  1. Generate a command template.
    $ go get -u github.com/spf13/cobra/cobra
    $ cobra init --pkg-name github.com/wdstar/go-cmd-example
    $ go mod tidy
    $ go build
    $ ./go-cmd-example 
    
  2. Add sub commands
    $ cobra add version -p "rootCmd"
    $ go build
    $ ./go-cmd-example version
    
  3. Add goreleaser configurations.
    $ curl -sL -o /usr/local/bin/goreleaser https://git.io/goreleaser
    $ chmod 755 /usr/local/bin/goreleaser
    $ goreleaser init
    # Snapshot build
    $ goreleaser --snapshot --skip-publish --rm-dist
    $ ./dist/go-cmd-example_linux_amd64/go-cmd-example version
    # Production release
    $ export GITHUB_TOKEN=**********************************
    $ git tag -a vX.X.X -m 'initial release.'
    $ git push --tags
    $ goreleaser --rm-dist
    

# Packages

Package cmd contains CLI implementations.