当前位置:网站首页>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函数。
边栏推荐
猜你喜欢

ESP8266-NodeMCU——从苏宁API获取实时天气

SOC的第一个Hello_World实验

百度编辑器上传图片设置自定义目录

Vinka introduces high anti-interference vk36n series touch IC: vk36n1d, vk36n2p, vk36n3b, vk36n4i, easy to use

Middle aged crisis, retired at the age of 35, what do migrant workers take to compete with capitalists?

MySQL soul 16 ask, how many questions can you hold on to?

(已解决)idea编译Gradle项目提示 错误找不到符号

自定义一个对象

FPGA HLS multiplier (pipeline vs. ordinary simulation)

【Redis】redis安装与客户端redis-cli的使用(批量操作)
随机推荐
单片机内部IO口保护电路及IO口电气特性以及为什么不同电压IO之间为什么串联一个电阻?
Introduction to Huawei's new version of datacom certification
7、 Logic of JMeter sending request
Go 接口:深入内部原理
15001.系统设计方案
低佣金账户怎么开?安全吗?
fastadmin,非超级管理员,已赋予批量更新权限,仍显示无权限
Why is apple x charging slowly_ IPhone 12 supports 15W MagSafe wireless charging. What will happen to iPhone charging in the future_ Charger
Niuke-top101-bm36
动态规划背包问题之完全背包详解
LeetCode之等式方程的可满足性
CA数字证书
Memory methods of big end mode and small end mode
《STM32MP1 M4裸机CubeIDE开发指南》第六章 STM32Cube固件包
Une solution complète au problème du sac à dos dans la programmation dynamique
Redis' expiration strategy and memory elimination mechanism. Why didn't you release memory when the key expired
SurFace家族选购参照
VRRP+MSTP配置详解【华为eNSP实验】
Oracle中实现删除指定查询条件的所有数据
Bean validation specification ----03