Last active
January 6, 2025 19:29
-
-
Save arxdsilva/4f73d6b89c9eac93d4ac887521121120 to your computer and use it in GitHub Desktop.
How to get the current working directory in golang
This file contains hidden or 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 | |
// More info on Getwd() | |
// https://golang.org/src/os/getwd.go | |
// | |
import( | |
"os" | |
"fmt" | |
"log" | |
) | |
func main() { | |
dir, err := os.Getwd() | |
if err != nil { | |
log.Fatal(err) | |
} | |
fmt.Println(dir) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For split path it is probably better to use
os.PathSeparator
constant