#2 Can't find work directory.

Zavřený
otevřeno před 2 roky uživatelem stevet · 1 komentářů

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 okomentoval před 2 roky
Spolupracovník

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.
Přihlaste se pro zapojení do konverzace.
Bez milníku
Bez zpracovatele
1 účastníků
Načítání...
Zrušit
Uložit
Není zde žádný obsah.