I just want to start a program written in go, to do this, you need to set the values ​​of the GOPATH and GOROOT variables with the export command. But how to do it through the system in PHP? As I understand it is a variable from the bash environment, and I just call the command of the operating system. I tried the system ("bash export GOROOT = mypatch"), and "sh export GOROOT = mypatch", there is no result.

  • Run or compile? - hardsky

1 answer 1

Setting environment variables in PHP is much easier; this is done with the putenv() function putenv()

 putenv("GOROOT=mypatch"); 

You, with your teams, launch new command shells, for which you set variables.