douqiao8370 2019-09-08 22:22
浏览 1101

Intellij IDEA(Golang)使用/ private / var / folders /

My Goland's runner (run/debug configurations) uses /private/var/folders/7b/50mzg8x17q55rxfg3b0kpj88xcm2lx/T in os.Args[0]. I know that os.Args[0] is the path to my program, but can I do os.Args[0] to be my working directory in Goland runner?

P.S. Working directory in Edit configurations set properly

  • 写回答

1条回答 默认 最新

  • douqian2957 2019-09-09 05:13
    关注

    I know that os.Args[0] is the path to my program, but can I do os.Args[0] to be my working directory in Goland runner?

    No, you cannot make os.Args[0] to be the working directory, since as you correctly identified, it's used to locate your program on disk.

    There are two changes you can make:

    • change your code to stop relying on os.Args[0] and start using os.Getwd() to get the working directory. Then you can edit your Run Configuration via Run | Edit Configurations... | <name of the run configuration> | Working Directory parameter.
    • if you really want you binary to be in a certain directory, then you can go to Run | Edit Configurations... | <name of the run configuration> | Output directory to have the IDE run the compiler and place the executable wherever you need to.

    If you need to make these changes for all future Run Configurations, then edit Run | Edit Configurations... | Templates | Go Build, or Go Test and change either the Working Directory or the Output Directory fields. Existing Run Configurations will not be changed.

    评论

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序