get current folder in golang code example
Example 1: golang get working directory
path, err := os.Getwd()
if err != nil {
log.Println(err)
}
fmt.Println(path) // for example /home/user
Example 2: golang get working directory
path, err := os.Executable()
if err != nil {
log.Println(err)
}
fmt.Println(path) // for example /tmp/go-build872132473/b001/exe/main