In the Go language specification its said things which needs to be exported outside package must starts with capital letter. I am wondering how error
interface is exposed outside and can be accessible anywhere even though it starts with small letter unlike other interfaces starts with capital letter like Stringer
.
error
is a builtin type just like int
, bool
, string
etc. I guess you've never wondered why int
is available despite starting with a lowecased letter.
Builtin types are predeclared identifiers, they are implicitly declared in the universe block and so available everywhere without any imports or qualifiers.