go-cli-fast-temp

command module
v0.0.0-...-7fb2483 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 27, 2023 License: Apache-2.0, MIT Imports: 8 Imported by: 0

README

golang-ci license go mod version GoDoc GoReportCard codecov docker version semver docker image size docker pulls github release

cli tools to init project fast

$ curl -L --fail https://raw.githubusercontent.com/sinlov/go-cli-fast-temp/main/temp-golang-cli-fast
# let template-golang-lib file folder under $PATH
$ chmod +x temp-golang-cli-fast
# see how to use
$ temp-golang-cli-fast -h

for what

  • this project used to cli with golang

Contributing

Contributor Covenant GitHub contributors

We welcome community contributions to this project.

Please read Contributor Guide for more information on how to get started.

Features

  • more perfect test case coverage
  • more perfect benchmark case

usage

  • use this template, replace list below
    • github.com/sinlov/go-cli-fast-temp to your package name
    • sinlov to your owner name
    • go-cli-fast-temp to your project name
    • go 1.18, ^1.18, 1.18.10 to new go version for dev

evn

  • minimum go version: go 1.18

libs

lib version
https://github.com/stretchr/testify v1.8.4

dev

depends

in go mod project

# warning use privte git host must set
# global set for once
# add private git host like github.com to evn GOPRIVATE
$ go env -w GOPRIVATE='github.com'
# use ssh proxy
# set ssh-key to use ssh as http
$ git config --global url."git@github.com:".insteadOf "http://github.com/"
# or use PRIVATE-TOKEN
# set PRIVATE-TOKEN as gitlab or gitea
$ git config --global http.extraheader "PRIVATE-TOKEN: {PRIVATE-TOKEN}"
# set this rep to download ssh as https use PRIVATE-TOKEN
$ git config --global url."ssh://github.com/".insteadOf "https://github.com/"

# before above global settings
# test version info
$ git ls-remote -q http://github.com/sinlov/go-cli-fast-temp.git

# test depends see full version
$ go list -mod readonly -v -m -versions github.com/sinlov/go-cli-fast-temp
# or use last version add go.mod by script
$ echo "go mod edit -require=$(go list -mod=readonly -m -versions github.com/sinlov/go-cli-fast-temp | awk '{print $1 "@" $NF}')"
$ echo "go mod vendor"

local dev

# It needs to be executed after the first use or update of dependencies.
$ make init dep
  • test code
$ make test testBenchmark

add main.go file and run

# run and shell help
$ make devHelp

# run at CLI_VERBOSE=true
$ make dev

# run at ordinary mode
$ make run
  • ci to fast check
# check style at local
$ make style

# run ci at local
$ make ci

docker

# then test build as test/Dockerfile
$ make dockerTestRestartLatest
# clean test build
$ make dockerTestPruneLatest

# more info see
$ make helpDocker

EngineeringStructure

.
├── Dockerfile                     # ci docker build
├── Dockerfile.s6                  # local docker build
├── Makefile                       # make entry
├── README.md
├── command                        # command line package
│         ├── TestMain.go             # common entry in unit test package
│         ├── flag.go                 # global flag
│         ├── global.go               # global command
│         ├── global_test.go          # global command unit test
│         ├── golder_data_test.go     # unit test test data case
│         ├── init_test.go            # unit test initialization tool
│         └── subcommand_new          # subcommandPackage new
├── constant                       # constant package 
│         └── env.go                  # constant environment variable
├── doc                            # command line tools documentation
│         └── cmd.md
├── go.mod
├── go.sum
├── main.go                        # command line entry
├── main_test.go                   # integrated test entry
├── package.json                   # command line profile information
├── utils                          # toolkit package
│         ├── env_kit                 # environment variables toolkit
│         ├── log                     # log toolkit
│         ├── pkgJson                 # package.json toolkit
│         └── urfave_cli              # urfave/cli toolkit
├── vendor
└── z-MakefileUtils                # make toolkit

log

package foo

func action(c *cli.Context) error {
	slog.Debug("SubCommand [ new ] start") // this not show at CLI_VERBOSE=false

	if c.Bool("lib") {
		slog.Info("new lib mode")
	}
	return nil
}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
utils
log

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL