我在运行简单的Go代码时遇到了一个错误。

huangapple go评论93阅读模式
英文:

I am facing an error while running simple go code

问题

我正在尝试运行一个简单的Go代码:

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版本:go1.17.5 darwin/arm64
  • macOS版本:monterey 12.1

错误信息:

# 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)
英文:

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)

答案1

得分: 1

以下命令可以帮助您:

尝试重新安装Xcode命令行工具并升级llvm和gcc。

$ brew upgrade llvm
$ brew upgrade gcc
$ sudo rm -rf /Library/Developer/CommandLineTools
$ xcode-select --install
英文:

Following commands helped me. <br> 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

huangapple
  • 本文由 发表于 2021年12月27日 19:34:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/70494946.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定