dsl2014 2014-10-08 16:53
浏览 10
已采纳

Go语言:“运行”时更改构建文件夹

Using Go on Windows, whenever I execute go run myprog.go from the console, Go builds a new executable with a random name somewhere on my C drive.

Is there a way to configure it so it will always build the file to a specific location, and preferably to also avoid the randomness of the name? (i.e., always build to D:\Temp\LastBuild.exe).

I was able to find some info that did not help when doing go help run and go help build. The latter had an output flag -o outfile but it is not accepted in go run.

Any help is appreciated.

  • 写回答

1条回答 默认 最新

  • dongliao3450 2014-10-08 17:21
    关注

    Do not use go run. It's intended for quick testing out snippets of code the size of a single screenful of lines.

    The working approach is

    1. Edit the code.
    2. go build it.
    3. Run your executable which will have predictable name.
    4. Go to step (1).

    If you write tests in parallel with the implementation (and you should), this changes to

    1. Edit the code.
    2. Edit the test suite.
    3. go test it.
    4. Go to step (1).

    Please see this recent thread on the mailing list for more insight on the same subject.

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

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大