Skip to content

Instantly share code, notes, and snippets.

@acerzhou
Last active June 9, 2020 00:08
Show Gist options
  • Save acerzhou/82e4a107057742d0f6f2ab44612f5928 to your computer and use it in GitHub Desktop.
Save acerzhou/82e4a107057742d0f6f2ab44612f5928 to your computer and use it in GitHub Desktop.
[GO CLI] go lang cli #go #cli
# Help Command
go help <command>
# Run go code
go run <go_program>
# Build code
go build <go_program>
# Build code and with dependency
go build -i <go_program>
# Build code to destination
go build -o <des_path> <go_program>
# Show Run, Build, Other process, but no result
go run/build/install -n <go_program>
# Show Run, Build, other process, witt the result
go run/build/install -x <go_program>
# Show Run, Build, Other process with the file name
go run/build/install -v <go_program>
# Check if code has racing problem
go run -race <go_program>
# Build Shared library
sudo /usr/local/go/bin/go build -buildmode=shared std
go install -linkshared -buildmode=shared <go_program>
go build -linkeshared <go_program>
# Go clean with process print
go clean -x
# Go fmt with process print
go fmt -x
# Go vet with process print - make sure code align guaidline
go vet -x
#### Go generator ###
# Show match tests
go test -list <expression> <path>
# Run match tests
go test -run <expression> <path>
# Make test timeout short
go test -short <path>
# Show detail of test
go test -v <path>
# Run test multiple times
go test -count 10 <path>
# Run test with coverage report
go test -cover <path>
# Run test with coverage package
go test -coverpkg <path>
# Generate coverage profile
go test -coverprofile cover.out(<file_name>) <path>
# Analyse the generated report
go tool cover -html=cover.out(<result_file_name>)
# Generate coverage profile report with how many times it runs
go test -covermode count -coverprofile cover.out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment