我在 运行 简单的 go 代码时遇到错误
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()
}
- 去版本:go1.17.5 darwin/arm64
- macOs : 蒙特雷 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)
以下命令对我有帮助。
尝试重新安装 Xcode 命令行工具并升级 llvm 和 gcc。
$ brew upgrade llvm
$ brew upgrade gcc
$ sudo rm -rf /Library/Developer/CommandLineTools
$ xcode-select --install
我正在尝试运行一个简单的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()
}
- 去版本:go1.17.5 darwin/arm64
- macOs : 蒙特雷 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)
以下命令对我有帮助。
尝试重新安装 Xcode 命令行工具并升级 llvm 和 gcc。
$ brew upgrade llvm
$ brew upgrade gcc
$ sudo rm -rf /Library/Developer/CommandLineTools
$ xcode-select --install