Skip to content

Instantly share code, notes, and snippets.

@CyrusRoshan
Last active June 8, 2018 22:11
Show Gist options
  • Save CyrusRoshan/6a5283492e9f60dd4a655c0eba54760f to your computer and use it in GitHub Desktop.
Save CyrusRoshan/6a5283492e9f60dd4a655c0eba54760f to your computer and use it in GitHub Desktop.
Restart program without checking for cgo errors
if os.Getenv("GODEBUG") != "cgocheck=0" {
cmd := exec.Command(os.Args[0], os.Args[1:]...)
env := os.Environ()
env = append(env, "GODEBUG=cgocheck=0")
cmd.Env = env
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err := cmd.Run()
fmt.Println(err)
os.Exit(0)
}
@CyrusRoshan
Copy link
Author

Automatically disable cgocheck without typing in the GODEBUG=cgocheck=0 flag or downgrading to 1.5. Put in the beginning of your go program so as not to rerun logic from the first run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment