Hacker News new | ask | show | jobs
by wnoise 3562 days ago
Why the exception for built-in types?
1 comments

I think it might be because you can't define methods on built-in types.

func (s *[]string) Foo() is not valid.

func (m map[int]string) Bar() is not valid.

That too, but I rather meant predeclared named types. According to Go specification, types that you define with "type Name OldName" are named, but "int", "string" and the rest are named too. Go disallows declaring methods on predeclared types.

https://golang.org/ref/spec#Types