Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: method undefined (type A2 has no field or method Len) #54687

Closed
zllangct opened this issue Aug 26, 2022 · 0 comments
Closed

cmd/go: method undefined (type A2 has no field or method Len) #54687

zllangct opened this issue Aug 26, 2022 · 0 comments

Comments

@zllangct
Copy link

What version of Go are you using (go version)?

$ go version

What did you do?

type A1 []int

func (a A1) Len() int {
	return len(a)
}

type A2 A1

func main() {
	a1 := make(A1, 0)
	println(a1.Len()) // ok

	a2 := make(A2, 0)
	println(a2.Len()) // error
}

What did you expect to see?

0
0

What did you see instead?

a2.Len undefined (type A2 has no field or method Len)

@golang golang locked and limited conversation to collaborators Aug 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants