I'm studying Go, I don't know if I missed something, but after searching, I wonder: Does dirname in NodeJS have an equivalent in Go? How to get current directory in Go code, or I have to implement one?
In Go you can use os.Getwd which returns a rooted path name corresponding to the current directory.
dir, err := os.Getwd()
if err != nil {
fmt.Errorf("Dir %v does not exists", err)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With