go vet && golint

This commit is contained in:
Yasuhiro Matsumoto 2016-11-05 00:46:04 +09:00
parent 0d1d1a644e
commit cde7293c72
1 changed files with 8 additions and 1 deletions

View File

@ -10,10 +10,13 @@ import "C"
// ErrNo inherit errno. // ErrNo inherit errno.
type ErrNo int type ErrNo int
// ErrNoMask is mask code.
const ErrNoMask C.int = 0xff const ErrNoMask C.int = 0xff
// ErrNoExtended is extended errno.
type ErrNoExtended int type ErrNoExtended int
// Error implement sqlite error code.
type Error struct { type Error struct {
Code ErrNo /* The error code returned by SQLite */ Code ErrNo /* The error code returned by SQLite */
ExtendedCode ErrNoExtended /* The extended error code returned by SQLite */ ExtendedCode ErrNoExtended /* The extended error code returned by SQLite */
@ -53,18 +56,22 @@ var (
ErrWarning = ErrNo(28) /* Warnings from sqlite3_log() */ ErrWarning = ErrNo(28) /* Warnings from sqlite3_log() */
) )
// Error return error message from errno.
func (err ErrNo) Error() string { func (err ErrNo) Error() string {
return Error{Code: err}.Error() return Error{Code: err}.Error()
} }
// Extend return extended errno.
func (err ErrNo) Extend(by int) ErrNoExtended { func (err ErrNo) Extend(by int) ErrNoExtended {
return ErrNoExtended(int(err) | (by << 8)) return ErrNoExtended(int(err) | (by << 8))
} }
// Error return error message that is extended code.
func (err ErrNoExtended) Error() string { func (err ErrNoExtended) Error() string {
return Error{Code: ErrNo(C.int(err) & ErrNoMask), ExtendedCode: err}.Error() return Error{Code: ErrNo(C.int(err) & ErrNoMask), ExtendedCode: err}.Error()
} }
// Error return error message.
func (err Error) Error() string { func (err Error) Error() string {
if err.err != "" { if err.err != "" {
return err.err return err.err
@ -122,7 +129,7 @@ var (
ErrConstraintTrigger = ErrConstraint.Extend(7) ErrConstraintTrigger = ErrConstraint.Extend(7)
ErrConstraintUnique = ErrConstraint.Extend(8) ErrConstraintUnique = ErrConstraint.Extend(8)
ErrConstraintVTab = ErrConstraint.Extend(9) ErrConstraintVTab = ErrConstraint.Extend(9)
ErrConstraintRowId = ErrConstraint.Extend(10) ErrConstraintRowID = ErrConstraint.Extend(10)
ErrNoticeRecoverWAL = ErrNotice.Extend(1) ErrNoticeRecoverWAL = ErrNotice.Extend(1)
ErrNoticeRecoverRollback = ErrNotice.Extend(2) ErrNoticeRecoverRollback = ErrNotice.Extend(2)
ErrWarningAutoIndex = ErrWarning.Extend(1) ErrWarningAutoIndex = ErrWarning.Extend(1)