Skip to content

Instantly share code, notes, and snippets.

@hiepndd
Forked from arxdsilva/working_directory.go
Created February 9, 2020 08:23
Show Gist options
  • Save hiepndd/90b54b6ba5aed736e103fb20562059b5 to your computer and use it in GitHub Desktop.
Save hiepndd/90b54b6ba5aed736e103fb20562059b5 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