Go で書き直した Ikemen
Revisão | 8812e010f19cd943af4fddc728286258dcd761ac (tree) |
---|---|
Hora | 2019-01-07 19:49:08 |
Autor | suehiro <supersuehiro@user...> |
Commiter | suehiro |
GOOS=windows でビルドできなかったのを修正
@@ -2,16 +2,19 @@ | ||
2 | 2 | package main |
3 | 3 | |
4 | 4 | import ( |
5 | - "syscal" | |
5 | + "os" | |
6 | + "syscall" | |
6 | 7 | ) |
7 | 8 | |
8 | -modkernel32 := syscall.NewLazyDLL("kernel32.dll") | |
9 | -procAllocConsole := modkernel32.NewProc("AllocConsole") | |
10 | -sscall.Syscall(procAllocConsole.Addr(), 0, 0, 0, 0) | |
11 | -hout, err1 := syscall.GetStdHandle(syscall.STD_OUTPUT_HANDLE) | |
12 | -hin, err2 := syscall.GetStdHandle(syscall.STD_INPUT_HANDLE) | |
13 | -if err1 != nil || err2 != nil { // nowhere to print the message | |
14 | - s.Exit(2) | |
9 | +func init() { | |
10 | + modkernel32 := syscall.NewLazyDLL("kernel32.dll") | |
11 | + procAllocConsole := modkernel32.NewProc("AllocConsole") | |
12 | + syscall.Syscall(procAllocConsole.Addr(), 0, 0, 0, 0) | |
13 | + hout, err1 := syscall.GetStdHandle(syscall.STD_OUTPUT_HANDLE) | |
14 | + hin, err2 := syscall.GetStdHandle(syscall.STD_INPUT_HANDLE) | |
15 | + if err1 != nil || err2 != nil { // nowhere to print the message | |
16 | + syscall.Exit(2) | |
17 | + } | |
18 | + os.Stdout = os.NewFile(uintptr(hout), "/dev/stdout") | |
19 | + os.Stdin = os.NewFile(uintptr(hin), "/dev/stdin") | |
15 | 20 | } |
16 | -os.Stdout = os.NewFile(uintptr(hout), "/dev/stdout") | |
17 | -os.Stdin = os.NewFile(uintptr(hin), "/dev/stdin") |