1.21.0 uses many go build folders making it impossible to exclude from antivirus

Ever since I installed go 1.21.0 I haven’t been able to use it because my antivirus blocks it. I do know how to exclude it but all the go build folders are random and there are many of it making it impossible to exclude them all. I could exclude the parent folder but the folder isn’t just for go so I still need to scan once in a while. Is there a way to configure go-build to only compile in a certain go-build folder
command-line-arguments: open C:\Users\user_name\AppData\Local\Temp\go-build3741852486\b001\exe\a.out.exe: Access is denied
Each time the go build folder changes.

You might have better luck contacting support for your antivirus program since this is more about that and potentially less about Go specifically.

I mean - you could have a folder like “c:\buildartifacts” or something where you tell your AV program to ignore it. Then you could use go build -o c:\buildartifacts\myprogram.exe. Though I’m not 100% sure if that fixes your problem or if I’m understanding you correctly.

Use GOCACHE in your enviroment
Then exclude C:\Go_workspace\go-build\ from antivirus

Thank you, but can you please explain a bit more. As in do I need to do this every go project or is this like go-build in appdata local. Also if I have to do it each time how do I make a go-build folder each time.

I have tried other languages with similar systems like rust but just by excluding the folder I am coding.

Also this is what happens if I try again: command-line-arguments: open C:\Users\user_name\AppData\Local\Temp\go-build3979163904\b001\exe\main.exe: Access is denied. The folder is different so I cannot exclude it.

This is and the reason before makes me think it is a problem with go making many go build folders.

I set this in the cmd before work and i do the same in vscode.bat ( I use a bat to set the enviroment before run )
this GOCACHE=C:\Go_workspace\go-build is for ALL PROJECTS

Sorry if I seem annoying but will it be where I installed it the folder. Should I just exclude where go-build is.
I am a bit new to go.

SET GOCACHE={Your folder} globaly in windows configuration
Make a .bat file to set this before start to build in CMD:
File: gopath.bat
SET GOCACHE=C:\Go_workspace\go-build
SET GOPATH=C:\Go_workspace
Make a .bat file seting this before open vscode.exe
File: VsCode_GO.bat
SET Path=C:\php-snap-build\deps_aux\oracle\x64\instantclient_12_1;C:\MinGW64\mingw64\bin;C:\Go\bin;C:\Go_workspace\bin;C:\Users\amichelins\go\bin;…
SET CGO_CFLAGS=-IC:/php-snap-build/deps_aux/oracle/x64/instantclient_12_1/sdk/include/
SET CGO_LDFLAGS=-LC:/php-snap-build/deps_aux/oracle/x64/instantclient_12_1/sdk/lib/msvc -loci
SET GOPATH=C:\Go_workspace
SET GOCACHE=C:\Go_workspace\go-build
CD C:\Go_workspace\src
@echo off
cls && start /b C:\Soft\VSCode_go\Code.exe

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.