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 孟德尔随机化结果不一致
  • ¥15 深度学习残差模块模型
  • ¥50 怎么判断同步时序逻辑电路和异步时序逻辑电路
  • ¥15 差动电流二次谐波的含量Matlab计算
  • ¥15 Can/caned 总线错误问题,错误显示控制器要发1,结果总线检测到0
  • ¥15 C#如何调用串口数据
  • ¥15 MATLAB与单片机串口通信
  • ¥15 L76k模块的GPS的使用
  • ¥15 请帮我看一看数电项目如何设计
  • ¥23 (标签-bug|关键词-密码错误加密)