Created
January 30, 2015 15:24
-
-
Save liuyanghejerry/bfcf44d49a31b703d89f to your computer and use it in GitHub Desktop.
exe path in golang
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 ( | |
"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