Skip to content

Instantly share code, notes, and snippets.

@shaunenslin
Created March 11, 2019 05:31
Show Gist options
  • Save shaunenslin/15ea2c2a133af2fe6565abf7f629c41e to your computer and use it in GitHub Desktop.
Save shaunenslin/15ea2c2a133af2fe6565abf7f629c41e to your computer and use it in GitHub Desktop.
GO Find a file next to your executable
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