go语言之go run/build/install/get
来源:互联网 发布:matlab模块化编程 编辑:程序博客网 时间:2024/05/24 07:12
go run
用于运行命令源码文件,只能接受一个命令源码文件以及若干个库文件作为参数
- go run 命令的常用标记参数:
- -a :强制编译相关代码
- -n:打印编译过程中所用的命令,但并不执行编译过程
- -x: 打印编译过程所需运行的命令,并执行编译;(注意和-n标记的区别)
- -p N :并行编译,其中N为并行的数量 (可以是逻辑cpu的个数),可以加速我们的编译速度
- -v:列出被编译的代码包的名称
- -work:显示编译时的临时工作目录的路径,并且不删除它
Inspiron-5759:~/goc2p/src/helper/ds$ go run -v showds.go command-line-argumentsgoc2p/src/helper/ds: showds.gogoc2p/src/helper/ds$ go run -work showds.go WORK=/tmp/go-build114678238/home/emindsoft/workdir/golang/xztlearn/goc2p/src/helper/ds: showds.go
go build
- 命令用于编译源码文件或代码包
编译非命令源码文件不会产生任何结果文件,只检查库文件的有效性;
- 编译命令源码文件时会在执行目录下生成可执行文件;
- 不加任何参数,会把当前目录作为代码包并编译;
- 执行该命令且以代码包的导入路径作为参数时,改代码包及其依赖会被编译;
- 执行该命令且以若干源码文件作为参数时,只有这些文件会被编译;
go build 命令的常用标记和go run 命令基本一致;
go install
- 编译并安装代码包或者源码文件
- 产生归档文件和可执行文件(默认为当前目录)
emindsoft@emindsoft-Inspiron-5759:~/workdir/golang/xztlearn/goc2p/src$ go help installusage: go install [build flags] [packages]Install compiles and installs the packages named by the import paths,along with their dependencies.For more about the build flags, see 'go help build'.For more about specifying packages, see 'go help packages'.See also: go build, go get, go clean.
- go get
Get downloads and installs the packages named by the import paths,along with their dependencies.The -d flag instructs get to stop after downloading the packages; that is,it instructs get not to install the packages.The -f flag, valid only when -u is set, forces get -u not to verify thateach package has been checked out from the source control repositoryimplied by its import path. This can be useful if the source is a local forkof the original.The -fix flag instructs get to run the fix tool on the downloaded packagesbefore resolving dependencies or building the code.The -insecure flag permits fetching from repositories and resolvingcustom domains using insecure schemes such as HTTP. Use with caution.The -t flag instructs get to also download the packages required to buildthe tests for the specified packages.The -u flag instructs get to use the network to update the named packagesand their dependencies. By default, get uses the network to check outmissing packages but does not use it to look for updates to existing packages.Get also accepts build flags to control the installation. See 'go help build'.
实例:
1.在kubernets的编译过程中我们采用如下方式拉取kubernets的源码:
$ go get -d k8s.io/kubernetes
阅读全文
0 0
- go语言之go run/build/install/get
- go run go build go install 命令解释
- 亲测GO环境搭建,理解go build、go install、go get
- go build 或者 go install 条件编译
- go build 和 go install 的区别
- 【Go】build 和 install命令
- Go命令基础之go run
- Go命令基础之go install
- Go命令基础之go build
- Go命令基础之go get
- go install
- install go
- Go Install
- Go语言之defer
- Go语言之介绍
- Go语言 Go加密之DES
- Go语言 Go加密之RSA
- Go并发编程之Go语言概述
- php 去除小数点后面的0,保留非零
- 重载和重写的底层实现
- [Leetcode] 342. Power of Four 解题报告
- 2017 多校赛6 Kirinriki hdu 6103
- Java学习笔记—String的用法
- go语言之go run/build/install/get
- 动态感知服务器上下线
- B
- opengl光照之聚光灯
- Java String面试题
- 手机淘宝的客户端架构探索之路
- Android 动态解析布局,实现制作多套主题
- 软件版本控制流程
- ps快速制作双重曝光效果