Skip to content

Instantly share code, notes, and snippets.

@wnoguchi wnoguchi/junkfile.go

Created Mar 17, 2018
Embed
What would you like to do?
Open junkfile golang windows version.
package main
import (
"fmt"
"time"
"bufio"
"io/ioutil"
"os"
"os/exec"
"strings"
)
func main() {
//fmt.Println("hello, world")
nowTime := time.Now()
const yyyymmdd = "2006/01/02"
const ymdhis = "20060102-150405"
str1 := nowTime.Format(yyyymmdd)
str2 := nowTime.Format(ymdhis)
fmt.Printf("now -> %s\n", str1)
fmt.Printf("now -> %s\n", str2)
reader := bufio.NewReader(os.Stdin)
fmt.Print(str2, "-")
text, _ := reader.ReadString('\n')
text = strings.TrimSuffix(text, "\r\n")
//text = text[:len(text)-2]
fmt.Println(text)
folderPath := "D:/Users/wnoguchi/Dropbox/Documents/junk/" + str1
os.MkdirAll(folderPath, os.ModePerm)
filePath := folderPath + "/" + str2 + "-" + text
fmt.Println(filePath)
d1 := []byte("")
//err := ioutil.WriteFile(filePath, d1, os.ModePerm)
ioutil.WriteFile(filePath, d1, os.ModePerm)
//if err := os.MkdirAll("hoge/fuga", 0777); err != nil {
// fmt.Println(err)
//}
//C:\Program Files\EmEditor\EmEditor.exe
//cmd:= exec.Command("cmd","/C","start","C:/Program Files/EmEditor/EmEditor.exe", filePath)
cmd:= exec.Command("C:/Program Files/EmEditor/EmEditor.exe", filePath)
//err:=cmd.Start()
cmd.Start()
//panic(err)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.