Go基础编程 - 02 - 命令

安装好Golang环境,可以在命令行执行 go 命令查看相关的Go语言命令:

PS C:\Users\Administrator> go
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
        work        workspace 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

Use "go help <command>" for more information about a command.

Additional help topics:

        buildconstraint build constraints
        buildmode       build modes
        c               calling between Go and C
        cache           build and test caching
        environment     environment variables
        filetype        file types
        go.mod          the go.mod file
        gopath          GOPATH environment variable
        gopath-get      legacy GOPATH go get
        goproxy         module proxy protocol
        importpath      import path syntax
        modules         modules, module versions, and more
        module-get      module-aware go get
        module-auth     module authentication using go.sum
        packages        package lists and patterns
        private         configuration for downloading non-public code
        testflag        testing flags
        testfunc        testing functions
        vcs             controlling version control with GOVCS

Use "go help <topic>" for more information about that topic.

Use go help <command> 查看相关命令详情:

+ `go version`  打印Go版本号

+ `go env  [-json] [-u] [-w] [var ...]`   用于打印Go语言的环境信息。

+ `go mod  <command> [arguments]` 使用go mod维护模块

+ `go get [-t] [-u] [-v] [build flags] [packages]`    向当前模块添加依赖项,并对它们进行编译和安装。

+ `go run [build flags] [-exec xprog] package [arguments...]` 编译并运行命令源码文件。

+ `go build [-o output] [build flags] [packages]` 编译包或依赖项

+ `go install  [build flags] [packages]`  编译并安装指定的代码包及它们的依赖包。

+ `go clean  [clean flags] [build flags] [packages]`  删除掉执行其它命令时产生的一些文件、目录和缓存文件。

+ `go list [-f format] [-json] [-m] [list flags] [build flags] [packages]`   列出指定的代码包和模块的信息。

+ `go fix [-fix list] [packages]` 把指定代码包的所有Go语言源码文件中的旧版本代码修正为新版本的代码。

+ `go doc [doc flags] [package|[package.]symbol[.methodOrField]]`    打印附于Go语言程序实体上的文档。我们可以通过把程序实体的标识符作为该命令的参数来达到查看其文档的目的。

+ `go bug`    开启一个Bug报告

+ `go test [build/test flags] [packages] [build/test flags & test binary flags]`  对Go语言编写的程序进行测试。

+ `go vet [-n] [-x] [-vettool prog] [build flags] [vet flags] [packages]`    用于检查Go语言源码中静态错误的简单工具。

+ `go tool [-n] command [args...]`   运行指定的go tool

+ `go work`   工作空间维护

+ `go generate [-run regexp] [-n] [-v] [-x] [build flags] [file.go... | packages]`   通过处理源码生成Go文件

+ `go fmt [-n] [-x] [packages]`    格式化源码包
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值