dsieyx2015 2017-01-03 14:07
浏览 91
已采纳

为用Go语言编写的Web应用程序设置什么GOARCH?

I want to deploy my webapp (basically CRUD) on DigitalOcean or a similar cloud provider. I found out that I can set GOARCH=386 or GOARCH=amd64. Both build properly on my computer.

How do I decide which one I need to deploy on server? There are all popular options like latest Ubuntu, Debian, CentOS.

  • 写回答

1条回答 默认 最新

  • duanjiong1952 2017-01-03 14:14
    关注

    Set the one that matches the architecture of your droplet. You can view this on your droplets list. Note that targeting the 386 platform you can run it on both 386 and amd64 platforms, while compiling to amd64 you can only run it on amd64.

    If you're asking which to choose, then it's up to you. Know that some operations are faster on amd64 (especially those which use / involve 64-bit values like int64), and also some features of the Go tool are only available if you target the amd64 architecture, for example the race detector, Supported Systems:

    The race detector runs on darwin/amd64, freebsd/amd64, linux/amd64, and windows/amd64.

    Executable binary size and memory usage is somewhat bigger for amd64, but it's not really an issue in case of Go, as a simple, running Go web server uses like 8 MB of memory. Unless you use excessively large arrays / slices like [big_number]int of course, as the size of int will be 4 bytes on 386 and 8 bytes on amd64.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用