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
Release: 2024-02-09 13:27:08
forward
624 people have browsed it

运行 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>
Copy after login

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>
Copy after login

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>
Copy after login

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
Copy after login

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!

Related labels:
source:stackoverflow.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template