英文:
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
点击“编辑配置”按钮
并将“工作目录”路径更改为您的程序应该“存在于”的位置。
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论