英文:
When building Go programs for release is it standard practice to just use 'go build'?
问题
构建Go程序时,是否只使用go build
而不使用其他选项是标准做法?我之所以问这个问题,是因为使用go build
构建时,默认情况下会包含所有的调试信息。要删除这些信息,可以向链接器传递一个选项,如下所示:
go build -ldflags "-w" prog.go
这将省略所有的调试符号。在构建发布版本的程序时,您会删除这些信息还是保留它们?
编辑:为了明确起见,我想知道人们如何编译Go程序以部署到实际环境中。在其他编译语言中,针对调试和发布构建,您会有不同的编译器命令行选项,并且发布构建通常会对可执行文件进行优化并删除调试信息。
英文:
When building Go programs for release is it standard practise to just use go build
without any other options? I ask because when building using go build
all debug information is included by default. To remove it you can pass an option to the linker, thus:
go build -ldflags "-w" prog.go
This omits all debug symbols. When building programs for release do you remove this information or leave it intact?
EDIT: For clarity, i'm wondering how people compile Go programs for deployment to a live environment. In other compiled languages you have a different set of compiler command line options for debugging and release builds and release builds usually optimise the executable and remove debugging information.
答案1
得分: 3
根据Dave Cheney的说法,答案是肯定的,只需使用go build
命令。
来源:http://www.reddit.com/r/golang/comments/2woogl/when_building_go_programs_for_release_is_it/
英文:
According to Dave Cheney the answer is yes, just use go build
.
Source: http://www.reddit.com/r/golang/comments/2woogl/when_building_go_programs_for_release_is_it/
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论