How to enable race detector for Golang in Visual Studio Code?

女生的网名这么多〃 提交于 2021-01-27 18:08:58

问题


I searched in many web pages to find what phrase exact should I place in settings.json in VS Code Golang extension (released by Microsoft) to add a build flag (in my case, race detector)?

I added:

"go.buildFlags": ["-race"],

in extension's settings.json but still when debugging, in a function that definitely generates a race condition, the debugging console does not denote something like:

Found 1 data race(s)

which the go compiler usually indicates when executing the same file via

go run -race file.go

回答1:


adding this line in settings.json

"go.testFlags": ["-race"]

works for me



来源:https://stackoverflow.com/questions/56668273/how-to-enable-race-detector-for-golang-in-visual-studio-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!