Created
December 10, 2016 16:56
-
-
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
This file contains 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
/* | |
{ | |
"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