Very slow building time on WSL2

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:
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)?

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