Created
December 10, 2016 17:05
-
-
Save hygull/12c8d4918fed3ef0393fa60a0069ea9e to your computer and use it in GitHub Desktop.
plateform independent directory creation created by hygull - https://repl.it/Emay/0
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 MAC/UNIX/Windows)" | |
"coded_by" : "Rishikesh Agrawani" | |
} | |
*/ | |
package main | |
import ( | |
"fmt" | |
"os" | |
"path/filepath" | |
) | |
func main() { | |
//In windows --> .\GolangDir | |
//In Unix/MAC --> ./GolangDir | |
//Lets do platform independent implementation for making directory in current working directory | |
if _, err := os.Stat("." + string(filepath.Separator) + "GolangDir"); os.IsNotExist(err) { | |
os.Mkdir("."+string(filepath.Separator)+"GolangDir", 0777) | |
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