Reading through the 7.8 section of "The Go Programming Language" I spotted following code:
var err error = syscall.Errno(2)
fmt.Println(err.Error()) // "no such file or directory"
fmt.Println(err) // "no such file or directory"
I understand the first and second line. error
interface is saitisfied by syscall.Errno
, thus Error()
function returning string
is available.
I don't understand third one. Going through syscall
's sources I can't find any place where syscall.Errno
satisfies stringer
interface - String()
function is not defined.
Why third one prints string representation of sysscall.Errno
?