当前位置:网站首页>go run,go build,go install有什么不同
go run,go build,go install有什么不同
2022-07-23 12:46:00 【ydl1128】
go run:go run 编译并直接运行程序,它会产生一个临时文件但不会生成 .exe 文件。
go build:go build 用于测试编译包,主要检查是否会有编译错误,如果是一个可执行文件的源码(即是 main 包),就会直接生成一个可执行文件。
如下所示:运行go build之后:会在当前目录生成.exe程序。当然,也可以指定目录和文件名:go build -o bin/my.exe 文件夹名

使用指定的文件名:
go install:go install 的作用有两步:第一步是编译导入的包文件,所有导入的包文件编译完才会编译主程序;第二步是将编译后生成的可执行文件放到 G O P A T H / b i n 目录下,编译后的包文件放到 p k g 目录下 GOPATH/bin目录下,编译后的包文件放到 pkg 目录下 GOPATH/bin目录下,编译后的包文件放到pkg目录下GOPATH/pkg。也就是.a编译文件。
如下所示:运行go install之后:会在 $GOPATH/bin生成.exe程序。此处pkg文件下没生成对应的包,是因为我操作的是main函数。
边栏推荐
- The competition boss is in Huawei: network experts are from Stanford physics department, and some people "work as much as reading a doctoral degree"
- Redis' expiration strategy and memory elimination mechanism. Why didn't you release memory when the key expired
- Éléments de base de la validation des haricots - 04
- MySQL - master-slave replication
- Life cycle, state management and local redrawing of fluent components | developers say · dtalk
- Go language learning - Review package, interface, file operation
- 阿里二面:MySQL 啥时候用表锁,啥时候用行锁?
- MySQL multi table query_ Inner connection_ Show internal connections
- ICML 2022 | sparse double decline: can network pruning also aggravate model overfitting?
- MySQL soul 16 ask, how many questions can you hold on to?
猜你喜欢

The new business form of smart civil aviation has emerged, and Tupo digital twin has entered the civil aviation flight network of the Bureau

IIS 部署.NetCore

C#入门系列(二十八) -- LINQ的查询语法

MySQL - master-slave replication

聊一聊JVM的内存布局

Fastadmin, non super administrator, has been granted batch update permission, but it still shows no permission

C#中单例模式的实现

Life cycle, state management and local redrawing of fluent components | developers say · dtalk
![Vrrp+mstp configuration details [Huawei ENSP experiment]](/img/d3/0334a9c6d6ee8c309712e73ed8c05a.png)
Vrrp+mstp configuration details [Huawei ENSP experiment]

table自定义表格的封装
随机推荐
智慧民航新业态崭露头角,图扑数字孪生入局民航飞联网
PgSQL mistakenly deletes PG_ Wal file, service startup failed
Ali Er Mian: when does MySQL use table locks and row locks?
20220721 beaten content
Calendar日历类
Cover - computer knowledge guide
CloudCompare&PCL 法向量空间采样(NSS)
Niuke-top101-bm36
AWS Part 1
Memory methods of big end mode and small end mode
Software detailed design template
WSAStartup函数的用途
pytest接口自动化测试框架 | 汇总
VMware platform STS certificate expired
移动端H5 - 手撸一个生命线 timeline
Bean validation core components - 04
20220722 beaten record
Go interface: go deep into internal principles
国产AI蛋白质结构预测再现突破,用单条序列解决3D结构,彭健团队:“AlphaFold2以来最后一块拼图补齐了”...
Mysql客户端到服务端字符集的转换