go build 参数_Go语言实战笔记(二)| Go开发工具

《Go语言实战》读书笔记,未完待续,第一时间看后续笔记。

在Go语言中,我们很多操作都是通过go命令进行的,比如我们要执行go文件的编译,就需要使用go build命令,除了build命令之外,还有很多常用的命令,这一次我们就统一进行介绍,对常用命令有一个了解,这样我们就可以更容易的开发我们的Go程序了。

42a86a9b0567d8cd9515a487ddc9da28.png

Go 开发工具概览

go这个工具,别看名字短小,其实非常强大,是一个强大的开发工具,让我们打开终端,看看这个工具有哪些能力。

➜  ~ goGo is a tool for managing Go source code.Usage:go command [arguments]The commands are:build       compile packages and dependenciesclean       remove object filesdoc         show documentation for package or symbolenv         print Go environment informationbug         start a bug reportfix         run go tool fix on packagesfmt         run gofmt on package sourcesgenerate    generate Go files by processing sourceget         download and install packages and dependenciesinstall     compile and install packages and dependencieslist        list packagesrun         compile and run Go programtest        test packagestool        run specified go toolversion     print Go versionvet         run go tool vet on packagesUse "go help [command]" for more information about a command.Additional help topics:c           calling between Go and Cbuildmode   description of build modesfiletype    file typesgopath      GOPATH environment variableenvironment environment variablesimportpath  import path syntaxpackages    description of package liststestflag    description of testing flagstestfunc    description of testing functionsUse "go help [topic]" for more information about that topic.

可以发现,go支持的子命令很多,同时还支持查看一些【主题】。我们可以使用go help [command]或者go help [topic]查看一些命令的使用帮助,或者关于某个主题的信息。大部分go的命令,都是接受一个全路径的包名作为参数,比如我们经常用的go build。

go build

go build,是我们非常常用的命令,它可以启动编译,把我们的包和相关的依赖编译成一个可执行的文件。

usage: go build [-o output] [-i] [build flags] [packages]

go build的使用比较简洁,所有的参数都可以忽略,直到只有go build,这个时候意味着使用当前目录进行编译,下面的几条命令是等价的:

go buildgo build .go build hello.go

以上这三种写法,都是使用当前目录编

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值