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

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

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