Golang Get Working Directory

[Solved] Golang Get Working Directory | Go - Code Explorer | yomemimo.com
Question : golang get working directory

Answered by : repulsive-rattlesnake-gu3cvrxkcaqj

path, err := os.Getwd()
if err != nil { log.Println(err)
}
fmt.Println(path) // for example /home/user

Source : https://yourbasic.org/golang/current-directory/ | Last Update : Tue, 20 Apr 21

Question : golang get working directory

Answered by : repulsive-rattlesnake-gu3cvrxkcaqj

path, err := os.Executable()
if err != nil { log.Println(err)
}
fmt.Println(path) // for example /tmp/go-build872132473/b001/exe/main

Source : https://yourbasic.org/golang/current-directory/ | Last Update : Tue, 20 Apr 21

Question : golang get current working directory

Answered by : revaz-gh

// Get current working directory (where run the command)
func pwd() string {	path, err := os.Getwd()	if err != nil {	fmt.Println(err)	}	return path
}

Source : | Last Update : Thu, 18 Aug 22

Answers related to golang get working directory

Code Explorer Popular Question For Go