Last active
December 28, 2016 04:26
-
-
Save HaiTo/8c2ea981600db1de303a9fec8e052c87 to your computer and use it in GitHub Desktop.
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
package main | |
import ( | |
"fmt" | |
homedir "github.com/mitchellh/go-homedir" | |
"os" | |
"time" | |
) | |
func main() { | |
dir, _ := homedir.Dir() | |
path := dir + "/,/" + time.Now().Format("20060102") + ".md" | |
// check file | |
_, exists_err := os.Stat(path) | |
if !os.IsNotExist(exists_err) { | |
fmt.Println("already created file is : " + path) | |
os.Exit(1) | |
} | |
// create file | |
if _, err := os.Create(path); err != nil { | |
fmt.Println(err) | |
os.Exit(1) | |
} | |
fmt.Println(path) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment