#2 Can't find work directory.

已关闭
stevet2 年之前创建 · 1 条评论

Running from cron, it can't find the work directory.

https://www.includehelp.com/golang/how-to-get-the-directory-of-the-currently-running-file-in-golang.aspx

import (
    "os"
    "path/filepath"
)

pathExecutable, err := os.Executable()
if err != nil {
    panic(err)
}
// Getting the directory path/name
dirPathExecutable := filepath.Dir(pathExecutable)
os.Chdir(dirPathExecutable)

That should have the program in the expected directory.

Running from cron, it can't find the work directory. https://www.includehelp.com/golang/how-to-get-the-directory-of-the-currently-running-file-in-golang.aspx ```go import ( "os" "path/filepath" ) pathExecutable, err := os.Executable() if err != nil { panic(err) } // Getting the directory path/name dirPathExecutable := filepath.Dir(pathExecutable) os.Chdir(dirPathExecutable) ``` That should have the program in the expected directory.
Steve Thielemann 评论于 2 年之前
协作者

On olympus, you'll see there's a roku.log in your home directory. (A symptom of this issue.) It won't find etherwake.

On olympus, you'll see there's a roku.log in your home directory. (A symptom of this issue.) It won't find etherwake.
stevet2 年之前 关闭
登录 并参与到对话中。
未选择里程碑
未指派成员
1 名参与者
正在加载...
取消
保存
这个人很懒,什么都没留下。