Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

unable to set CGO_ENABLED=1

So I am trying to run my code from visual studio code using the command

go run -race .

This is giving me the error:

go: -race requires cgo; enable cgo by setting CGO_ENABLED=1

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I tried setting it by using the command but nothing happens:

set CGO_ENABLED=1

Can somebody tell me how to set the CGO_ENABLED env variable to 1 because I am not able to do it

>Solution :

You can write a batch script run.bat to run your code:

set CGO_ENABLED=1
go run -race .

To accomplish this in Visual Studio Code, you can modify the environment variables via a launch script, see this question:

Is there any way to set environment variables in Visual Studio Code?

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading