GolangNote

Golang笔记

golang cannot refer to unexported name

Permalink

出现这个错误的原因你可能想不到

plaintext: unexported
1
2
golang cannot refer to unexported name
不能引用未导出名称

大部分的原因是因为:

plaintext: 修正
1
函数或变量名首字母是小写

Go: 大小写变量名
1
2
3
4
type my struct {
    a   string // 不能在本包外被引用,引用可能会有以上报错
    B  string // 可以在本包外被引用
}

本文网址: https://golangnote.com/topic/127.html 转摘请注明来源

Related articles

Golang http IPv4/IPv6 服务

Golang 的网络服务,如果不指定IPv4 或 IPv6,如果VPS 同时支持 IPv4 和 IPv6,`net.Listen()` 只会监听 IPv6 地址。但这不影响客户端使用 IPv4 地址来访问。...

Write a Comment to "golang cannot refer to unexported name"

Submit Comment Login
Based on Golang + fastHTTP + sdb | go1.20 Processed in 3ms