Reputation: 411
Is error type in Go "Error" or "error"? It bugged me that in the Tour it is with small first letter so I looked around and found here with small e yet here in source code it is with big capital letter. Also how can it be without big capital letter yet still visible outside of package?
Just started learning Go so I might have missed something basic, thanks.
Upvotes: 2
Views: 1014
Reputation: 963
error
is the type, lowercase. Just like with int
and string
it doesn't need to be visible as it is built-in to Go:
A good blog post on error handling
The runtime
package you're referring to has an Error
interface. The type there is an interface not error:
type Error interface {
error
// RuntimeError is a no-op function but
// serves to distinguish types that are run time
// errors from ordinary errors: a type is a
// run time error if it has a RuntimeError method.
RuntimeError()
}
The Error interface identifies a run time error.
Upvotes: 5