Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding the current working directory programmatically in go?

Tags:

go

I have been looking trough the go documentation but so far I haven't found anything. I need help to find the current working directory programmaticly in go language. Does any one know how to do that?

like image 628
Pablo Jomer Avatar asked Aug 31 '26 19:08

Pablo Jomer


1 Answers

Getwd from the os package will return your current working directory. For more operating system related functions look in the os package.

If you want to print it do the following.

import (
    "fmt"
    "os"
)

func main() {
    wd, _ := os.Getwd()
    fmt.Println("Working Directory:", wd)
}
like image 109
JimB Avatar answered Sep 04 '26 12:09

JimB



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!