Home > OS >  I am facing an error while running simple go code
I am facing an error while running simple go code

Time:01-04

I am trying to run a simple go code

package main
import (
    "log"
    "net/http"
    "fmt"
)
func homePage(w http.ResponseWriter, r *http.Request) {

}
func handleRequest() {
    http.HandleFunc("/", homePage)
    log.Fatal(http.ListenAndServe(":8081", nil))
}

func main() {
    handleRequest()
}
  • Go version : go1.17.5 darwin/arm64
  • macOs : monterey 12.1

Error Message:

# runtime/cgo
ld: unsupported tapi file type '!tapi-tbd' in YAML file '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks//CoreFoundation.framework/CoreFoundation.tbd' for architecture arm64
clang-10: error: linker command failed with exit code 1 (use -v to see invocation)

CodePudding user response:

Following commands helped me.
Try to reinstall Xcode command-line tools and upgrade llvm and gcc.

$ brew upgrade llvm
$ brew upgrade gcc
$ sudo rm -rf /Library/Developer/CommandLineTools
$ xcode-select --install
  • Related