Created
March 11, 2019 05:31
-
-
Save shaunenslin/15ea2c2a133af2fe6565abf7f629c41e to your computer and use it in GitHub Desktop.
GO Find a file next to your executable
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
var s string | |
var err error | |
s, err = os.Executable() | |
if err != nil { | |
return "", errors.Wrap(err, "os.executable") | |
} | |
ext := filepath.Ext(s) | |
outfile := s[0:len(s)-len(ext)] + ".toml" | |
return outfile, nil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment