Golang-“ go run main.go”之间的区别和编译 [英] Golang - Difference between "go run main.go" and compilation
本文介绍了Golang-“ go run main.go”之间的区别和编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Go中编写了一些脚本之后,我问我自己: .go
文件的编译与以后的执行以及从性能等方面运行FILE.go
命令。
After writing some scripts in Go I asked myself if there is any difference between the compilation of a .go
-file and the later execution and the go run FILE.go
command in terms of performence etc.
如果我使用以下方法之一启动Web服务,是否有任何优势?
Are there any advantages if I start a webservice with one of these methods?
推荐答案
开始运行
只是编译的快捷方式,然后在一小步。尽管它对开发很有用,但通常应将其构建并在生产中使用它时直接运行二进制文件。
go run
is just a shortcut for compiling then running in a single step. While it is useful for development you should generally build it and run the binary directly when using it in production.
这篇关于Golang-“ go run main.go”之间的区别和编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文