go语言常见命令

191 阅读1分钟

Go is a tool for managing Go source code.

Usage:

go <command> [arguments]

The commands are:

bug         start a bug report
build       compile packages and dependencies
clean       remove object files and cached files
doc         show documentation for package or symbol
env         print Go environment information
fix         update packages to use new APIs
fmt         gofmt (reformat) package sources
generate    generate Go files by processing source
get         add dependencies to current module and install them
install     compile and install packages and dependencies
list        list packages or modules
mod         module maintenance
run         compile and run Go program
test        test packages
tool        run specified go tool
version     print Go version
vet         report likely mistakes in packages

其中经常使用的有

build       compile packages and dependencies
get         add dependencies to current module and install them
install     compile and install packages and dependencies
run         compile and run Go program
test        test packages
tool        run specified go tool

build 编译软件包和依赖关系

get 添加依赖关系到当前模块并安装他

install 编译并安装软件包和依赖关系

run 编译并且启动go程序

test 测试包

tool 启动go工具