In-reply-to » I did a take home software engineering test for a company recently, unfortunately I was really sick (have finally recovered) at the time 😒 I was also at the same time interviewing for an SRE position (as well as Software Engineering).

@lyse@lyse.isobeef.org I think the most interesting thing about errors.New() is just how stupidly simple it really is:

// New returns an error that formats as the given text.
// Each call to New returns a distinct error value even if the text is identical.
func New(text string) error {
	return &errorString{text}
}

// errorString is a trivial implementation of error.
type errorString struct {
	s string
}

func (e *errorString) Error() string {
	return e.s
}

That’s it! πŸ˜‚

​ Read More