vscode-go icon indicating copy to clipboard operation
vscode-go copied to clipboard

Problems with windows defender

Open jhon1607 opened this issue 2 years ago • 7 comments

What version of Go, VS Code & VS Code Go extension are you using?

Version Information
  • Run go version to get version of Go from the VS Code integrated terminal.

    • <1.20.2>
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.

    • <0.11.0>
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.

    • <1.76.2>
  • Check your installed extensions to get the version of the VS Code Go extension

    • <0.38.0>
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.

    • <
    • Checking configured tools.... GOBIN: undefined toolsGopath: gopath: C:\Users\sanch\Home\Projects\Go GOROOT: C:\Program Files\Go PATH: C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files\Git\cmd;C:\Users\sanch\Home\Projects\Go\bin;;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\nodejs;C:\Program Files\Go\bin;%PNPM_HOME%;C:\Users\sanch\AppData\Local\Microsoft\WindowsApps;C:\Program Files\heroku\bin;C:\Users\sanch\AppData\Roaming\npm;C:\Users\sanch\go\bin;C:\Program Files\go-comment-splitter;C:\Users\sanch\AppData\Local\Programs\Microsoft VS Code\bin

    go: C:\Program Files\Go\bin\go.exe: go version go1.20.2 windows/amd64

    gotests: C:\Users\sanch\Home\Projects\Go\bin\gotests.exe (version: v1.6.0 built with go: go1.20.2) gomodifytags: C:\Users\sanch\Home\Projects\Go\bin\gomodifytags.exe (version: v1.16.0 built with go: go1.20.2) impl: C:\Users\sanch\Home\Projects\Go\bin\impl.exe (version: v1.1.0 built with go: go1.20.2) goplay: C:\Users\sanch\Home\Projects\Go\bin\goplay.exe (version: v1.0.0 built with go: go1.20.2) dlv: C:\Users\sanch\Home\Projects\Go\bin\dlv.exe (version: v1.20.1 built with go: go1.20.2) staticcheck: C:\Users\sanch\Home\Projects\Go\bin\staticcheck.exe (version: v0.4.2 built with go: go1.20.2) gopls: C:\Users\sanch\Home\Projects\Go\bin\gopls.exe (version: v0.11.0 built with go: go1.20.2)

go env Workspace Folder (Katze): c:\Users\sanch\home\dev\projects\servers\Go\Katze set GO111MODULE= set GOARCH=amd64 set GOBIN= set GOCACHE=C:\Users\sanch\AppData\Local\go-build set GOENV=C:\Users\sanch\AppData\Roaming\go\env set GOEXE=.exe set GOEXPERIMENT= set GOFLAGS= set GOHOSTARCH=amd64 set GOHOSTOS=windows set GOINSECURE= set GOMODCACHE=C:\Users\sanch\Home\Projects\Go\pkg\mod set GONOPROXY= set GONOSUMDB= set GOOS=windows set GOPATH=C:\Users\sanch\Home\Projects\Go set GOPRIVATE= set GOPROXY=https://proxy.golang.org,direct set GOROOT=C:\Program Files\Go set GOSUMDB=sum.golang.org set GOTMPDIR= set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64 set GOVCS= set GOVERSION=go1.20.2 set GCCGO=gccgo set GOAMD64=v1 set AR=ar set CC=gcc set CXX=g++ set CGO_ENABLED=0 set GOMOD=c:\Users\sanch\home\dev\projects\servers\Go\Katze\go.mod set GOWORK= set CGO_CFLAGS=-O2 -g set CGO_CPPFLAGS= set CGO_CXXFLAGS=-O2 -g set CGO_FFLAGS=-O2 -g set CGO_LDFLAGS=-O2 -g set PKG_CONFIG=pkg-config set GOGCCFLAGS=-m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=C:\Users\sanch\AppData\Local\Temp\go-build2914934687=/tmp/go-build -gno-record-gcc-switches - >

Share the Go related settings you have added/edited

Run Preferences: Open Settings (JSON) command to open your settings.json file. Share all the settings with the go. or ["go"] or gopls prefixes.

Describe the bug

When I save a Go file, Antimalware Service executable consumes all the system resources, I came to the conclusion that the error was caused by the extension because when I deactivate it, the error disappears and when I activate it, it happens again.A clear and concise

I have few extensions and I had to deactivate them all and activate them one by one, so I came to know that it was the go extension that caused the error.

Steps to reproduce the behavior:

  1. Go to 'Opens a vscode and task manager window.'
  2. Click on 'Create a go file, place contents in it and click save, without taking your eyes off the Antimalware Service Executable process. '
  3. See error

Screenshots or recordings

jhon1607 avatar Mar 19 '23 23:03 jhon1607

/cc @findleyr

jamalc avatar Mar 24 '23 14:03 jamalc

CC @hyangah

I am not sure what we can do to help here. Our builds are open source and verifiable. If windows defender detects a problem, that seems like a windows defender bug? Without more information, I'm afraid this is not actionable on our end.

Can you share more about the windows defender error? Does it identify the problematic executable (e.g. gopls)?

findleyr avatar Mar 29 '23 18:03 findleyr

The extension depends on the go binary and a few compiled Go tools. If virus scanner interferes with the operation, this extension won't work. See https://go.dev/doc/faq#virus

Can you configure the scanner to exclude the tools this extension installs?

(you can inspect the current tools location from the go explorer view or using "Go: Locate Configured Go Tools" command) Screenshot 2023-03-29 at 4 23 00 PM

You may be able to configure your extension to install the tools in a specified location (using "go.toolsGopath" setting) and configure the virus scanning program to exclude the directory.

hyangah avatar Mar 29 '23 20:03 hyangah

@hyangah hi, I'm not the author of this topic, but I encountered the exact same behaviour with Windows Defender CPU load striking in space close to 100% cpu usage.

Can you configure the scanner to exclude the tools this extension installs?

~~I did what you proposed - added all go tools and go.exe itself in scanner exceptions list, but it didn't help at all (nothing changed, I see no improvements).~~

~~I've been fighting this issue for like several months already, and still can't solve it completely - the only thing I see on the internet is that every ticket on github in every repo is being closed without solution blaming Windows Defender.~~

~~The only thing that helped me quite a lot is disabling some vscode extensions I didn't really needed at the moment, but even after disabling them and having all go tools, vscode and go.exe in scanner exceptions list - windows defender still occupies cpu.
(Maybe it is indeed how defender works and we can't do anything about this on Windows, I've lost hope already)
~~

Upd.: What actually helped me and dropped Defender cpu usage close to 0 is adding go.exe and gopls.exe to scanner exclusions "As Process" (and marking asked checkbox in popup) - not as just file or like folder providing path to it (excluded like this 2 ways didn't help), but only using Windows Defender option "exclude as process" and providing exact processes names. May or not this solution be considered as more vulnerable to malicious software from scanner perspective - I have no idea.

Dmitrevicz avatar Mar 31 '23 10:03 Dmitrevicz

Thanks @Dmitrevicz for sharing your experience. This extension heavily depends on running go and gopls (on windows, go.exe and gopls.exe). So windows defender blocking or slowing down these processes will prevent this extension and also go from running. It's unfortunate, but I don't know other ways to make windows defender happy about go and their tools. Can any of you contribute to a documentation to help other windows users who have similar experience? https://github.com/golang/vscode-go/blob/master/docs/troubleshooting.md can have a dedicated section for windows users :-)

hyangah avatar Apr 13 '23 01:04 hyangah

Upd.: What actually helped me and dropped Defender cpu usage close to 0 is adding go.exe and gopls.exe to scanner exclusions

This extension heavily depends on running go and gopls (on windows, go.exe and gopls.exe). So windows defender blocking or slowing down these processes will prevent this extension and also go from running.

@Dmitrevicz @hyangah thanks for your tips, this helped to significantly improve CPU usage when dealing with go on windows

yury-kozlov avatar Jun 20 '23 00:06 yury-kozlov

Upd.: What actually helped me and dropped Defender cpu usage close to 0 is adding go.exe and gopls.exe to scanner exclusions "As Process" (and marking asked checkbox in popup) - not as just file or like folder providing path to it (excluded like this 2 ways didn't help), but only using Windows Defender option "exclude as process" and providing exact processes names. May or not this solution be considered as more vulnerable to malicious software from scanner perspective - I have no idea.

Thanks, helped me, too. Seems to be some problem with the Go Compiler & Windows Defender, my CPU usage from Windows Defender was spiking around 65% while compiling without VSCode being loaded; I think it has only to do with this extension insofar as it runs the compiler in the background and is a rather a problem of WD.

Simon-Martens avatar Jan 17 '24 09:01 Simon-Martens