debugging golang in intellij – not finding relative files

huangapple go评论85阅读模式
英文:

debugging golang in intellij - not finding relative files

问题

我正在处理一个使用golang的项目,需要从子目录中读取文件...

在调试程序时(还不确定it是什么),当提供相对路径时,它无法找到文件。我在这个操作中使用io.util.ReadFile(RELATIVE_PATH)

当从终端运行程序时,这个问题不会出现。

这让我相信IntelliJ在调试/运行时会在幕后进行一些操作,可能会影响目录结构(将其移动到临时位置?)。如果是这种情况,我该如何配置IntelliJ,使子目录包含在这个操作中,或者取消这个操作,以便从所在目录调试程序。

我对golang/IntelliJ都不太熟悉,所以任何帮助都将不胜感激。

英文:

I'm working on a golang project that has to read files from a sub directory...

When debugging my program it (not sure what it is yet) is unable to locate the files when provided a relative path. Im using io.util.ReadFile(RELATIVE_PATH) for this operation.

This problem doesn't occur when running the program from the terminal.

This has lead me to believe intellij does something behind the scenes debugging/running where it messes with the directory structure (moves it into a temporary location?). If this is the case, how would I go about configuring intellij so that the sub directories are included in the magic or removing the magic so the program is debugged from the directory it lives in.

I'm new to golang/intellij so any help would be appreciated.

答案1

得分: 3

点击“编辑配置”按钮

debugging golang in intellij – not finding relative files

并将“工作目录”路径更改为您的程序应该“存在于”的位置。

debugging golang in intellij – not finding relative files

英文:

Click on "Edit Configurations"

debugging golang in intellij – not finding relative files

and change the "Working directory" path to where your program should "live in".

debugging golang in intellij – not finding relative files

huangapple
  • 本文由 发表于 2016年2月19日 02:57:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/35490118.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定