github.com/cnboonhan/delve@v0.0.0-20230908061759-363f2388c2fb/pkg/gobuild/defaultexe.go (about) 1 package gobuild 2 3 import ( 4 "io/ioutil" 5 "runtime" 6 7 "github.com/go-delve/delve/pkg/logflags" 8 ) 9 10 // DefaultDebugBinaryPath returns an unused file path in the current 11 // directory named 'name' followed by a random string 12 func DefaultDebugBinaryPath(name string) string { 13 pattern := name 14 if runtime.GOOS == "windows" { 15 pattern += "*.exe" 16 } 17 f, err := ioutil.TempFile(".", pattern) 18 if err != nil { 19 logflags.DebuggerLogger().Errorf("could not create temporary file for build output: %v", err) 20 if runtime.GOOS == "windows" { 21 return name + ".exe" 22 } 23 return name 24 } 25 r := f.Name() 26 f.Close() 27 return r 28 }