package pgdriverimport ()// Error represents an error returned by PostgreSQL server// using PostgreSQL ErrorResponse protocol.//// https://www.postgresql.org/docs/current/static/protocol-message-formats.htmltypeErrorstruct { m map[byte]string}// Field returns a string value associated with an error field.//// https://www.postgresql.org/docs/current/static/protocol-error-fields.htmlfunc ( Error) ( byte) string {return .m[]}// IntegrityViolation reports whether an error is a part of// Integrity Constraint Violation class of errors.//// https://www.postgresql.org/docs/current/static/errcodes-appendix.htmlfunc ( Error) () bool {switch .Field('C') {case"23000", "23001", "23502", "23503", "23505", "23514", "23P01":returntruedefault:returnfalse }}func ( Error) () string {returnfmt.Sprintf("%s #%s %s", .Field('S'), .Field('C'), .Field('M'))}func ( error, bool) bool {switch {casenil:returnfalsecasedriver.ErrBadConn:returntrue }if , := .(Error); {switch .Field('V') {case"FATAL", "PANIC":returntrue }switch .Field('C') {case"25P02", // current transaction is aborted"57014": // canceling statement due to user requestreturntrue }returnfalse }if {if , := .(net.Error); && .Timeout() {return !.Temporary() } }returntrue}
The pages are generated with Goldsv0.3.6. (GOOS=darwin GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.