如何在Windows 10上安装Go的GCC?

I want to use external library on Go programming language and i am using this command for instance :

go get github.com/alecthomas/gozmq

from command line, but it gives such an error:

github.com/pebbe/zmq4 exec: "gcc": executable file not found in %PATH%

i tried to install Cygwin, but it doesn't fixed the error

Cygwin setup as default installs only a minimal set of packages, the core ones. If you need additional one as a compiler you need to specifically require it

https://cygwin.com/cygwin-ug-net/setup-net.html#setup-packages

In your case as go is unlikey a cygwin program, you can not use the cygwin compiler to extend your go language. You could try the mingw64 project

https://mingw-w64.org/

First I would ask you if you are developing on windows or if you are only trying to compile your code for windows.

If you are developing on windows I strongly suggest installing the "Windows Subsystem for Linux" and running go in there. This will make your live a lot easier when it comes to running/compiling cgo stuff. Note: Installing mingw is the alternative but that will make your hair go grey.

If you need to compile for windows (windows is your target system) then I suggest using xgo. It uses docker containers to compile to many different OS' in a single command.

Summary: You can easily compile for windows without cgo, but when cgo is involved use unix for development and xgo for build (automation).