I'm testing simple Go program on Windows 8 with SublimeText3 (GoSublime plugin)
go run -v example.go
and before run it's being compiled inside ..AppData\Local\Temp.. directory. My antivirus program thinks that it's a virus and blocks it:
fork/exec C:\Users\D24F7~1.KAP\AppData\Local\Temp\go-build333212398\command-line-arguments_obj\exe\example.exe: Access is denied.
I can't disable it and my solution is to change the folder where it's being compiled. How can I do that?
I change ouput directory
go build -i -o D:\Users\MyProj\out\
-o flag
and put to antivirus ignoring D:\Users\MyProj\out\ directory
The WORK directory (seen if building or running with the -x flag) is taken from the TMP environment variable. Updating that variable through the system properties will change the working directory.
The GOTMPDIR environment var can be used to control the work directory. This is usually preferable to modifying the system-wide temporary directory. GOTMPDIR was introduced in go 1.10.
Before
> go run -work .\example.go
WORK=C:\Users\MyUserName\AppData\Local\Temp\go-build1002945170
...
Modify permanently in the System Properties > Environment Variables window or temporarily in the shell
# powershell
$env:GOTMPDIR = "C:\Users\MyUserName\MyGoBuilds"
After
> go run -work .\example.go
WORK=C:\Users\MyUserName\MyGoBuilds\go-build1381354702
...
Then you can make the needed antivirus or other security exceptions on the GOTMPDIR directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With