go核心36讲 16-20

xiaoxiao2025-04-23  10

19 | 错误处理(上)

type error interface { Error() string }

 

// New returns an error that formats as the given text. 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 }

 

转载请注明原文地址: https://www.6miu.com/read-5028945.html

最新回复(0)