Comment

Comment by im-a-baby

Generally, returning a typed error in the function signature in Go is very annoying and dangerous. An example why:

    import "fmt"
    
    type MyError struct{}
    
    func (m *MyError) Error() string {
     return ""
    }

    func myFunc() *MyError {
     return nil
    }
    
    func main() {
     var err error
     err = myFunc()
     if err == nil {
      fmt.Println("No Error")
     } else {
      fmt.Println("Error") // This prints
     }
    }
parent im-a-baby 4 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton