github.com/machinefi/w3bstream@v1.6.5-rc9.0.20240426031326-b8c7c4876e72/pkg/depends/x/goid/patch/main.go (about) 1 package main 2 3 import ( 4 "fmt" 5 "go/build" 6 "io/ioutil" 7 "os" 8 "os/exec" 9 "path" 10 ) 11 12 var patcher = []byte(`package runtime 13 14 func GoID() int64 { 15 return getg().goid 16 } 17 `) 18 19 func main() { 20 pkg, err := build.Default.Import("runtime", "", build.FindOnly) 21 if err != nil { 22 fmt.Println("err:", err) 23 } 24 err = ioutil.WriteFile(path.Join(pkg.Dir, "proc_id.go"), patcher, os.ModePerm) 25 if err != nil { 26 fmt.Println("err:", err) 27 } 28 _, err = exec.Command("go", "install", "runtime").CombinedOutput() 29 if err != nil { 30 fmt.Println("err:", err) 31 } 32 }