Home >Backend Development >Golang >Unable to determine name type in C.getnameinfo in go when running go build

Unable to determine name type in C.getnameinfo in go when running go build

WBOY
WBOYforward
2024-02-09 13:27:08617browse

运行 go 构建时无法确定 go 中 C.getnameinfo 的名称类型

php editor Xiaoxin is here to introduce to you a problem about the inability to determine the name type of C.getnameinfo in go when running go build. In the process of building using the go language, sometimes you will encounter a problem, that is, the name type of the C.getnameinfo function cannot be determined. This problem may cause build failures or other compilation errors. This article will introduce the cause and solution of this problem in detail, hoping to help developers who encounter the same problem.

Question content

So I just upgraded my go version to a higher version go1.20.2 Previously I used go1.18.x.

I have updated the environment path of go

<code>export GOPATH="$HOME/go";
export GOROOT="$HOME/.go"; 
export PATH="$GOPATH/bin:$PATH";
</code>

So, every time I try to build it always shows these errors

<code>/home/usr/.go/src/net/cgo_resnew.go:21:17: could not determine kind of name for C.getnameinfo
</code>

I've been looking for the answer but I didn't get it from the internet. Does anyone know what causes this error?

When to do it

<code>go build .
</code>

It should not show this error

/home/usr/.go/src/net/cgo_resnew.go:21:17: could not determine kind of name for C.getnameinfo

Solution

Use the command go env to check CGO_ENABLED in the golang environment. If your value CGO_ENABLED is 1, you must set the value to 0. If you use zsh, add export CGO_ENABLED=0 on ~/.bashrc or ~/.zshrc (I recommend adding environment variables on ~/.profile for global settings)

The above is the detailed content of Unable to determine name type in C.getnameinfo in go when running go build. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:stackoverflow.com. If there is any infringement, please contact admin@php.cn delete