doucong7963 2015-09-05 17:55
浏览 473

要生成纯静态链接的二进制文件,是否仍需要在Go 1.5+中使用-tags netgo进行编译?

I'm trying to create a pure statically linked binary to run in a minimal Docker container. Prior to Go 1.5, I was building them like this:

go build -a -tags netgo -installsuffix netgo myfile.go

I understand that C has been stripped out of the Go compiler in version 1.5. Is it still necessary to build with -tags and -installsuffix?

  • 写回答

1条回答 默认 最新

  • dqs13465424392 2015-09-05 18:44
    关注

    https://golang.org/doc/go1.5#net

    The DNS resolver in the net package has almost always used cgo to access the system interface. A change in Go 1.5 means that on most Unix systems DNS resolution will no longer require cgo, which simplifies execution on those platforms. Now, if the system's networking configuration permits, the native Go resolver will suffice. The important effect of this change is that each DNS resolution occupies a goroutine rather than a thread, so a program with multiple outstanding DNS requests will consume fewer operating system resources.

    The decision of how to run the resolver applies at run time, not build time. The netgo build tag that has been used to enforce the use of the Go resolver is no longer necessary, although it still works. A new netcgo build tag forces the use of the cgo resolver at build time. To force cgo resolution at run time set GODEBUG=netdns=cgo in the environment. More debug options are documented here.

    This change applies to Unix systems only. Windows, Mac OS X, and Plan 9 systems behave as before.

    So no.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作