On Wed, Dec 16, 2020 at 8:49 AM Sean <s.tolstoyev...@gmail.com> wrote:
>
> hi all,
> i have a project I have to work with CGo. I want to disable some
> controls as they are not good enough right now.
> It works when I write "set godebug=cgocheck=0" on Windows in console.
> However, this is a GUI program. Console should not open.
>
> I tried this with "os.Setenv". I define it in "func init" it doesn't work.
>
> Something like this:
>
> func init() {
>      os.Setenv("godebug", "cgocheck=0")
> }
>
> What should I do?

At present I believe that the best you can do is something like, in
main (untested):

    if os.Getenv("GODEBUG") == "" {
        cmd := exec.Command(os.Args[0], os.Args[1:]...)
        cmd.Env = append(os.Environ(), "GODEBUG=cgocheck=0")
        if err := cmd.Run(); err != nil {
            os.Exit(1)
        }
        os.Exit(0)
    }

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcXVReo%2BbBf5ZawwO3QcMUEkRMy5QFxgUbG%2BuOjmmyCT5A%40mail.gmail.com.

Reply via email to