Skip to content

Latest commit

 

History

History
155 lines (125 loc) · 4.75 KB

dev.md

File metadata and controls

155 lines (125 loc) · 4.75 KB

dev

env

libs

lib version
https://github.com/stretchr/testify v1.9.0
https://github.com/sebdah/goldie v2.5.3
https://github.com/gookit/color v1.5.3
https://github.com/urfave/cli/ v2.27.2

depends

in go mod project

# warning use private 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 "https://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 https://github.com/bridgewwater/temp-golang-cli-fast.git

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

dev tasks

# It needs to be executed after the first use or update of dependencies.
make init dep
  • test code
make test
# benchmark and coverage show
make ci.test.benchmark ci.coverage.show
  • ci to fast check as CI pipeline
# 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
├── build                          # build output
├── cmd
│     └── temp-golang-cli-fast     # command line main package install and dev entrance
│         ├── main.go                   # command line entry
│         └── main_test.go              # integrated test entry
├── 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
│         └── dev.md
├── go.mod
├── go.sum
├── package.json                   # command line profile information
├── resource.go                    # embed resource 
├── 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

import (
	"github.com/bridgewwater/temp-golang-cli-fast/constant"
	"github.com/bridgewwater/temp-golang-cli-fast/internal/d_log"
)

// GlobalBeforeAction
// do command Action before flag global.
func GlobalBeforeAction(c *cli.Context) error {
	isVerbose := c.Bool(constant.NameKeyCliVerbose)
	if isVerbose {
		d_log.OpenDebug()
	}
	return nil
}

func Biz() {
	d_log.Debug("debug log")
	d_log.Debugf("debug log")
}