Source file
src/syscall/mksyscall_windows.go
1
2
3
4
5
6
7
8 package main
9
10 import (
11 "bytes"
12 "os"
13 "os/exec"
14 "path/filepath"
15 "runtime"
16 )
17
18 func main() {
19 goTool := filepath.Join(runtime.GOROOT(), "bin", "go")
20
21 listCmd := exec.Command(goTool, "list", "-m")
22 listCmd.Env = append(os.Environ(), "GO111MODULE=on")
23
24 var (
25 cmdEnv []string
26 modArgs []string
27 )
28 if out, err := listCmd.Output(); err == nil && string(bytes.TrimSpace(out)) == "std" {
29
30
31 cmdEnv = append(os.Environ(), "GO111MODULE=on")
32
33
34
35
36
37
38
39
40 modArgs = []string{"-mod=readonly"}
41 } else {
42
43
44
45
46 os.Stderr.WriteString("WARNING: Please switch from using:\n go run $GOROOT/src/syscall/mksyscall_windows.go\nto using:\n go run golang.org/x/sys/windows/mkwinsyscall\n")
47 }
48
49 args := append([]string{"run"}, modArgs...)
50 args = append(args, "golang.org/x/sys/windows/mkwinsyscall")
51 args = append(args, os.Args[1:]...)
52 cmd := exec.Command(goTool, args...)
53 cmd.Stdout = os.Stdout
54 cmd.Stderr = os.Stderr
55 cmd.Env = cmdEnv
56 err := cmd.Run()
57 if err != nil {
58 os.Exit(1)
59 }
60 }
61
View as plain text