<p>i have a go web app . i want it to run in another machine without installing golang in that machine,is there any way to run as a single exe</p>
<hr/>**评论:**<br/><br/>gopherNoodle: <pre><p>run <code>go build</code> or <code>go install</code> and copy the resulting binary to the target machine.</p></pre>ebadf: <pre><p>Yes, that's what <code>go build</code> does. It creates an executable binary from Go source code. For example, if you have a file <code>main.go</code>, and you run <code>go build main.go</code>, you will get an executable <code>main</code> that you can copy to another machine and run it there without a Go installation.</p>
<p>If the other machine has a different OS or architecture, you'll need to set the environment variables <code>GOOS</code> or <code>GOARCH</code>. For instance, I use OSX for writing Go, but I want to create an executable that runs on Linux, so I use <code>GOOS=linux go build main.go</code>.</p></pre>osozer: <pre><p>All golang related binaries are imported statically in golang binaries, so you can use any golang binary whereever you want If only the operating systems are the same.</p></pre>alexaandru: <pre><p>If you're using nothing but the standard library then the <code>go build</code> should do what you need. However if you're using a framework, it depends on the framework. If you use some lighter one, like <a href="https://echo.labstack.com/" rel="nofollow">https://echo.labstack.com/</a> then sure, you can create static binaries. If OTOH you're using something like Revel, then you're out of luck: <a href="https://github.com/revel/revel/issues/589" rel="nofollow">https://github.com/revel/revel/issues/589</a> Seems like Beego is in the same boat: <a href="https://github.com/beego/bee/issues/310" rel="nofollow">https://github.com/beego/bee/issues/310</a></p></pre>metacasts: <pre><p>Check out gobuffalo.io it will generate complete stand alone binaries, include templates, migrations, assets, etc… Plus, it’s pretty fun to use to build web apps. :)</p></pre>
run a go web app as a single exe in another machine without installing go in that machine
xuanbao · · 510 次点击这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传