Go programs won't run after MacOS Catalina upgrade

Issue

This might be a weird question, but some programs written in Go won’t run on my MacBook Pro after MacOS Catalina upgrade.

However a basic "Hello World" program runs, but then I am using the writing a program using net/http package I get the following error:

Note: The programs are correct, they run fine inside a Docker container

Output (IntelliJ):


# runtime/cgo
In file included from gcc_darwin_amd64.c:6:
/usr/local/include/pthread.h:331:6: error: macro expansion producing 'defined' has undefined behavior [-Werror,-Wexpansion-to-defined]
/usr/local/include/pthread.h:200:2: note: expanded from macro '_PTHREAD_SWIFT_IMPORTER_NULLABILITY_COMPAT'
/usr/local/include/pthread.h:331:6: error: macro expansion producing 'defined' has undefined behavior [-Werror,-Wexpansion-to-defined]
/usr/local/include/pthread.h:200:34: note: expanded from macro '_PTHREAD_SWIFT_IMPORTER_NULLABILITY_COMPAT'
/usr/local/include/pthread.h:540:6: error: macro expansion producing 'defined' has undefined behavior [-Werror,-Wexpansion-to-defined]
/usr/local/include/pthread.h:200:2: note: expanded from macro '_PTHREAD_SWIFT_IMPORTER_NULLABILITY_COMPAT'
/usr/local/include/pthread.h:540:6: error: macro expansion producing 'defined' has undefined behavior [-Werror,-Wexpansion-to-defined]
/usr/local/include/pthread.h:200:34: note: expanded from macro '_PTHREAD_SWIFT_IMPORTER_NULLABILITY_COMPAT'

Things that I have already tried:

  1. Reinstall go
  2. Reinstall xcode
  3. Check if GOPATH & GOROOT are properly set

Used:

MacOS version - Catalina 10.15.6
Go version - go1.15.2 darwin/amd64

Solution

Sadly, none of the tryouts worked.

I have been using IntelliJ IDEA Ultimate for sometime now.. so I tried to setup Go SDK, GOROOT and GOPATH using the IDE (just a thought came to my mind).

I uninstalled/deleted everything related to Go on my MacBook.

Then I installed the Go plugin on IntelliJ IDEA and as expected it prompted that Go SDK is not available, neither GOROOT and GOPATH are set.

I followed the instructions and IntelliJ IDEA took care of the rest!

It downloaded and installed Go SDK, asked me to select GOPATH, it indexed stuff and now every thing is working like a charm!

Answered By – rav

Answer Checked By – Marie Seifert (GoLangFix Admin)

Leave a Reply

Your email address will not be published.