Skip to content

Instantly share code, notes, and snippets.

@liuyanghejerry
Created January 30, 2015 15:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liuyanghejerry/bfcf44d49a31b703d89f to your computer and use it in GitHub Desktop.
Save liuyanghejerry/bfcf44d49a31b703d89f to your computer and use it in GitHub Desktop.
exe path in golang
package main
import (
"fmt"
"log"
"os"
"path/filepath"
)
func main () {
filename := os.Args[1] // get command line first parameter
filedirectory := filepath.Dir(filename)
thepath, err := filepath.Abs(filedirectory)
if err != nil {
log.Fatal(err)
}
fmt.Println(thepath)
}
// provided by https://www.socketloop.com/tutorials/golang-get-current-file-path-of-a-file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment