Created
April 6, 2022 08:54
-
-
Save teocci/4af946fb41234e71ed82cd4a2677853a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"path" | |
"path/filepath" | |
"runtime" | |
) | |
var ( | |
// Current working directory | |
cwdPath, _ = os.Getwd() | |
// from Executable Directory | |
x, _ = os.Executable() | |
executablePath = filepath.Dir(x) | |
// Relative on runtime DIR: | |
_, b, _, _ = runtime.Caller(0) | |
relativePath = filepath.Dir(b) | |
) | |
func DirPaths() { | |
fmt.Println("CWD PATH:", cwdPath) | |
fmt.Println("Executable PATH:", filepath.Dir(executablePath)) | |
fmt.Println("Relative PATH:", relativePath) | |
d := path.Join(path.Dir(b)) | |
fmt.Println("Relative-d PATH:", filepath.Dir(d)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment