Skip to content

Instantly share code, notes, and snippets.

@hygull
Created December 10, 2016 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hygull/c69063efb1e48f8d0dadec20d38b8faf to your computer and use it in GitHub Desktop.
Save hygull/c69063efb1e48f8d0dadec20d38b8faf to your computer and use it in GitHub Desktop.
Creating a new directory in cwd created by hygull - https://repl.it/Emak/4
/*
{
"cretaed_after" : "Sat Dec 10 12:01:49 IST 2016"
"aim_of_program" : "To create a new directory in current working directory (On Unix based system)"
"coded_by" : "Rishikesh Agrawani"
}
*/
package main
import "os"
import "fmt"
func main() {
//This is for MAC Or UNIX machines that uses / as path separator.
//For platform independent path separators check my next gist(on github)/post
if _, err := os.Stat("./UploadDir"); os.IsNotExist(err) {
os.Mkdir("UploadDir", 0777) /* 0777 denotes file permission */
fmt.Println("Directory created.")
} else {
fmt.Println("Directory exists.")
}
}
/*FIRST RUN:-
Directory created.
SECOND RUN:-
Directory exists.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment