I have a gorilla/mux based web service written in Golang. I've observed that the exact same code produces a binary of size more than 10 MB on my Windows 10 Pro Machine while its about 7 MB on my colleague's Windows 10 Pro Machine. On yet another colleague's MacBook Pro running OS X Yosemite, the binary is just a bit over 11 MB in size. What does this binary actually contain?!
关注
码龄 粉丝数 原力等级 --
- 被采纳
- 被点赞
- 采纳率
duan5731
2016-08-26 06:58浏览 131
已采纳
Golang-为什么在类似计算机上进行编译会导致二进制文件大小明显不同?
图片转代码服务由CSDN问答提供
感谢您的意见,我们尽快改进~
功能建议
感谢您的意见,我们尽快改进~
我有一个用Golang编写的基于大猩猩/ mux的Web服务。 我观察到生成的代码完全相同 Windows 10专业版计算机上的二进制文件大小超过10 MB,而同事的Windows 10专业版计算机上的文件大小约为7 MB。 在另一位运行OS X Yosemite的同事的MacBook Pro上,该二进制文件的大小仅略超过11 MB 。 此二进制文件实际上包含什么?! p> div>
- 写回答
- 好问题 提建议
- 追加酬金
- 关注问题
微信扫一扫
分享- 邀请回答
1条回答 默认 最新
- 关注
码龄 粉丝数 原力等级 --
- 被采纳
- 被点赞
- 采纳率
douzhang1955 2016-08-26 07:12最佳回答 专家已采纳It may be due to different architectures (
GOARCH
env variable). Rungo env
to verify. Compiled binary to386
and toamd64
differs significantly (compiled toamd64
is significantly bigger), but it should be close if the architecture is the same with different OS.Also the Go version itself matters a lot, Go 1.7 reduced the compiled binary size. See blog post Smaller Go 1.7 binaries for details.
Also I assume it's the same, but whether debug info is excluded can reduce the compiled binary size significantly.
采纳该答案 已采纳该答案 专家已采纳评论解决 无用打赏举报微信扫一扫
分享评论登录 后可回复...
报告相同问题?
提交
相关推荐 更多相似问题
- 2016-08-26 06:58回答 1 已采纳 It may be due to different architectures (GOARCH env variable). Run go env to verify. Compiled bin
- 2017-05-24 03:28回答 1 已采纳 Disclaimer first: I'm no expert of compilation toolchains and executable file formats. I'll try no
- 2016-06-05 10:21回答 2 已采纳 Nevermind, found the answer [ `strings $pkg_a_file | grep 'go object' | head -n 1 | cut -f 5 -d '
- 2020-09-20 03:44主要给大家介绍了关于Golang如何交叉编译各个平台的二进制文件的相关资料,并介绍了golang如何让编译生产的二进制文件变小,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
- 2019-08-14 03:05Bins是一个小型的Up应用程序,用于为需要交叉编译的Golang二进制文件提供服务。 您的程序的消费者不需要安装Go,也不需要为每个发行版和平台交叉编译二进制文件。
- 2021-03-11 18:26是一种按需二进制服务器,它允许非Go用户快速安装使用Go编写的工具,而无需安装go本身,从而消除了交叉编译的负担,并为您编写的每个命令行上传了数十个二进制文件。 用法 使用可选的semver VERSION安装PKG 。 curl...
- 2015-02-09 18:38回答 1 已采纳 So let me answer my own question by concluding, after weeks of trial and error, that… …it just do
- 2017-02-10 22:02回答 2 已采纳 When you type a command without giving the full path, your system will try to find it within all t
- 2017-08-15 22:39回答 1 已采纳 It looks like Go is using system's native DNS resolution code (via a C library) when compiling loc
- 2021-05-10 12:42Android二进制文件解析器 高级API 解析APK文件 package main import ( "github.com/shogo82148/androidbinary/apk" ) func main () { pkg , _ := apk . OpenFile ( "your-android-app.apk" ) defer pkg ...
- 2019-09-18 09:02goupx, 在x86_64上,以便与UPX打包,修复golang编译的二进制文件 goupx-- 修复 golang Linux ELF可执行文件与upx一起工作更新:2016/03/10据我所知,对于Linux二进制文件来说,不再是必需的,因为它是在 go1.6....
- 2021-05-26 16:19genesis Genesis是一个实用程序,用于将静态文件资产嵌入到Go文件中以包含在静态编译中。 Genesis包括对http.FileSystem的支持以及通过SHA1哈希的版本控制。 安装genesis Genesis是用于将静态文件资产嵌入到Go文件中...
- 2018-03-27 09:49回答 1 已采纳 By doing go build you are creating a binary for the go program in that current folder. Update On
- 2015-02-11 16:15回答 4 已采纳 Go 1.5 and above edit: As of now, the syntax has changed. Use go build -ldflags "-X main.Version
- 2017-03-20 09:31回答 2 已采纳 output, err := exec.Command("./test","flag1", "arg1", "flag2", "arg2").Output() Output returns bo
- 2021-02-10 13:19设置运行golang编译出来的二进制文件。 附加的功能 SSH,用于开启22端口 FRP把码头工人的端口,映射给别的机器,这样可以隐藏运行机器 时区是+008 rsyslog切割日志 go特定扩展 libvips,支持图片的功能
- 2021-05-27 14:20带有嵌入golang的C#二进制文件hack-browser-data Sharp-HackBrowserData来自https://github.com/moonD4rk/HackBrowserData的Hack#BrowserData的C#包装程序我这样做主要是为自己进行实验,将golang二进制文件嵌入...
- 2021-05-26 19:06Docker镜像,用于使用基于Alpine Linux的MinGW-w64工具链为Windows构建Go二进制文件。 go-mingw Docker映像,用于使用基于Alpine Linux的MinGW-w64工具链为Windows构建Go二进制文件。 该映像为Windows 32/64位版本...
- 2019-09-13 10:19回答 1 已采纳 @LinPy Thank you for u help. https://www.x-cellent.com/blog/cgo-bindings/ I solved the problem.
- 2021-05-21 14:39我妈说我是八婆的博客 最近一位朋友问我“为什么同样的hello world 入门程序”为什么golang编译出来的二进制文件,比 C 大,而且大很多。我做了个测试,来分析这个问题。C 语言的hello world程序:#include int main() {printf("hello ...
- 没有解决我的问题, 去提问