Golang 编译的时候,是不是把第三库所有的函数都编译进去了
資深大佬 : wellhome 12
引用了一个第三方包, 只用到其中一部分函数,那些没有用到的函数是不是也被编译到静态二进制文件中了?
大佬有話說 (8)
https://blog.golang.org/go1.7-binary-size
The second change is method pruning. Until 1.6, all methods on all used types were kept, even if some of the methods were never called. This is because they might be called through an interface, or called dynamically using the reflect package. Now the compiler discards any unexported methods that do not match an interface. Similarly the linker can discard other exported methods, those that are only accessible through reflection, if the corresponding reflection features are not used anywhere in the program. That change shrinks binaries by 5–20%.