Last active
June 8, 2018 22:11
-
-
Save CyrusRoshan/6a5283492e9f60dd4a655c0eba54760f to your computer and use it in GitHub Desktop.
Restart program without checking for cgo errors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.