google go create folder

Golang create directory

Creating a directory from Google Go is simple with the “os” package. See the example below.

Golang create directory example

path := "/folder/to/create"
err := os.MkdirAll(path,0711)

if err != nil {
 log.Println("Error creating directory")
 log.Println(err)
 return
}

Leave a Reply

Your email address will not be published. Required fields are marked *