rodrigocfd / windigo

Windows API and GUI in idiomatic Go.

Home Page:https://pkg.go.dev/github.com/rodrigocfd/windigo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to set environment variables in `CreateProcess`?

UnderCooled opened this issue · comments

  proxy := readConfig()
  env := []struct {
    name string
    val string
  }{{"HTTPS_PROXY", proxy}, {"HTTP_PROXY", proxy}}
  
  win.CreateProcess(
    win.StrOptSome("C:\\Program Files (x86)\\AppFlowy\\AppFlowy.exe"),
    win.StrOptSome(""), &mySecurityAttr, &mySecurityAttr, true, co.CREATE_NO_WINDOW,
    env,
    win.StrOptSome("."), &myStartupInfo, &myProcessInfo)
go version go1.21.6 windows/amd64

.\appflowy_proxifier.go:59:5: cannot use env (variable of type []struct{name string; val string}) as []struct{name string; val string} value in argument to win.CreateProcess

This error is confusing.