shad-go/lectures/02-interfaces/temporary/main.go

19 lines
224 B
Go
Raw Normal View History

package main
import "errors"
type Temporary interface {
IsTemporary() bool
}
func do() error { return nil }
func main() {
err := do()
var terr Temporary
if errors.As(err, &terr) && terr.IsTemporary() {
//...
}
}