【Go】Go 命令

导读:本篇文章讲解 【Go】Go 命令,希望对大家有帮助,欢迎收藏,转发!站点地址:www.bmabk.com


一、go 命令有哪些?

如果你已安装了 golang 环境,你可以在 cmd 命令行执行 go 命令查看相关的 Go语言命令:

C:\Users\huipu>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
        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.

go env 用于打印Go语言的环境信息。

go run 命令可以编译并运行源码文件。

go get 可以根据要求和实际情况从互联网上下载或更新指定的代码包及其依赖包,并对它们进行编译和安装。

go build 命令用于编译我们指定的源码文件或代码包以及它们的依赖包。

go install 用于编译并安装指定的代码包及它们的依赖包。

go clean 命令会删除掉执行其它命令时产生的一些文件和目录。

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

go test 命令用于对Go语言编写的程序进行测试。

go list 命令的作用是列出指定的代码包的信息。

go fix 会把指定代码包的所有Go语言源码文件中的旧版本代码修正为新版本的代码。

go vet 是一个用于检查Go语言源码中静态错误的简单工具。

go tool pprof 命令来交互式的访问概要文件的内容。


一、常用 go 命令

  1. 查看源代码 main.go 在底层都做了些什么:go tool compile -S main.go

参考链接

  1. 命令

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/119026.html

(0)
seven_的头像seven_bm

相关推荐

发表回复

登录后才能评论
极客之音——专业性很强的中文编程技术网站,欢迎收藏到浏览器,订阅我们!