Skip to content

Instantly share code, notes, and snippets.

@d1y
Forked from arxdsilva/working_directory.go
Created March 30, 2020 03:57
Show Gist options
  • Save d1y/1a03d0f3aaaf9f640e1d246dac4a43ef to your computer and use it in GitHub Desktop.
Save d1y/1a03d0f3aaaf9f640e1d246dac4a43ef to your computer and use it in GitHub Desktop.
How to get the current working directory in golang
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