I have a rather small project that is building in native Windows in around ~10-20s. The same project takes minutes to build when using a WSL2 terminal.
→ Yes, WSL is accessing the Windows filesystem (/mnt) and is therefore usually a bit slower. However, running
go build -x
shows that go is running
git status --porcelaine
which takes about 90% of the total build time.
After some research I found that issue: https://github.com/microsoft/WSL/issues/4401.
It basically says Git needs to refresh its index on every “git status”, because of the WSL and Windows filesystem mixture. The solution is to create an alias to the Windows wsl.exe inside of WSL. This works great, but unfortunately not for the Go build. “git status” still takes forever.
So, is Go using some kind of “shielded” shell to prevent aliases to work? Is there any possibility to edit/configure the go building process (e.g. to use a different git command)?