惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 三生石上(FineUI控件)
Blog — PlanetScale
Blog — PlanetScale
B
Blog
GbyAI
GbyAI
爱范儿
爱范儿
月光博客
月光博客
N
Netflix TechBlog - Medium
T
Tailwind CSS Blog
G
Google Developers Blog
大猫的无限游戏
大猫的无限游戏
Vercel News
Vercel News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
WordPress大学
WordPress大学
The GitHub Blog
The GitHub Blog
Recent Announcements
Recent Announcements
腾讯CDC
MyScale Blog
MyScale Blog
V
Visual Studio Blog
The Cloudflare Blog
Microsoft Security Blog
Microsoft Security Blog
A
About on SuperTechFans
Google DeepMind News
Google DeepMind News
Last Week in AI
Last Week in AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻

博客园 - hikoming

Privacy Policy for Hurry Pee PhotoTool Compress/Remove EXIF Privacy Policy for PhotoTool Compress/Remove EXIF Privacy Policy for Units Converter Pro7 Units Converter Pro7 - Convert Any Unit Privacy Policy for DigitalPet DigitalPet-Tamagotchi in watch Privacy Policy for DiceRoll 3D DiceRoll on watch two dice 无痕换字(TextGhost) 隐私政策 无痕改字-AI智能替换 Privacy Policy for EasyCalc EasyCalc: Calculate Anything, Effortlessly.* yii2-验证规则,rules,判断条件 关于html5调用手机相机(原创) (iOS)开发中收集的小方法 (iOS)关于@property和@synthesize的理解(原创) 我的iOS-App Xcode的Architectures、Valid Architectures和Build Active Architecture Only属性(原创) IOS设备型号(原创)
让 go build 生成的可执行文件对 Mac、linux、Windows 平台一致
hikoming · 2021-06-28 · via 博客园 - hikoming

让 go build 生成的可执行文件对 Mac、linux、Windows 平台一致

要做到这一点,使用的是交叉编译选项。

CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build main.go

CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build main.go

CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build main.go

确定目标机器的系统和架构,在运行 go build 的环境中,运行命令之前指定好相应的参数值。