登录
首页 >  Golang >  Go问答

`go build` 使用 `-o` 输出标记会产生副作用吗?

来源:stackoverflow

时间:2024-02-05 22:39:20 103浏览 收藏

大家好,我们又见面了啊~本文《`go build` 使用 `-o` 输出标记会产生副作用吗?》的内容中将会涉及到等等。如果你正在学习Golang相关知识,欢迎关注我,以后会给大家带来更多Golang相关文章,希望我们能一起进步!下面就开始本文的正式内容~

问题内容

来自 go build 的文档页面:

The -o flag forces build to write the resulting executable or object to the named output file or directory, instead of the default behavior described in the last two paragraphs. If the named output is an existing directory or ends with a slash or backslash, then any resulting executables will be written to that directory.

但是我遇到的构建过程本质上是:

go build -o foo src/
mv foo bar

是否有我在文档中找不到的这样做的原因?例如。它是否将链接器符号名称设置为 foo 或类似的名称?或者这只是一个我可以放心忽略的怪癖?


正确答案


通过查看具有相同源和不同 -o 标志的 go build 生成的二进制文件的校验和,这些文件绝对相同。所以没有副作用。

理论要掌握,实操不能落!以上关于《`go build` 使用 `-o` 输出标记会产生副作用吗?》的详细介绍,大家都掌握了吧!如果想要继续提升自己的能力,那么就来关注golang学习网公众号吧!

声明:本文转载于:stackoverflow 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>