windows机器环境,go程序使用race定位时一运行就报错,写了个example如:
能看到加了race之后就不行了,
搜了一下,git上有个issue: runtime: Race detector causes exit status 0xc0000139 on Windows 11 with 1.21rc2 running gcc 9.2.0 · Issue #61058 · golang/go · GitHub
里面有个大哥说了一句:
Given that the binary works with a newer GCC, this sounds like a GCC bug rather than a Go bug.
然后查了一下,当前的GCC版本是8,

更新了一下,然后就好用了:


这里需要注意的是GCC的更新,别用这个 MinGW Installation Manager 这个东西,这玩意最多只能更新到6.几的版本;
也别用 mingw-w64-install.exe,这个最多只能更新到8.1;
直接去git上 mingw-builds-binaries 下载安装包自己装: Releases · niXman/mingw-builds-binaries · GitHub
下载对应的版本解压之后改一下环境变量重启VSCODE就行了