From 4bde157d91c6061ab47312761ca440d2b06bdb25 Mon Sep 17 00:00:00 2001 From: Mario Trangoni Date: Tue, 17 Apr 2018 11:13:35 +0200 Subject: [PATCH] fix all goconst issues --- sqlite3.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sqlite3.go b/sqlite3.go index 8c83e4d..3273da4 100644 --- a/sqlite3.go +++ b/sqlite3.go @@ -141,6 +141,12 @@ var SQLiteTimestampFormats = []string{ "2006-01-02", } +const ( + columnDate string = "date" + columnDatetime string = "datetime" + columnTimestamp string = "timestamp" +) + func init() { sql.Register("sqlite3", &SQLiteDriver{}) } @@ -1039,7 +1045,7 @@ func (rc *SQLiteRows) Next(dest []driver.Value) error { case C.SQLITE_INTEGER: val := int64(C.sqlite3_column_int64(rc.s.s, C.int(i))) switch rc.decltype[i] { - case "timestamp", "datetime", "date": + case columnTimestamp, columnDatetime, columnDate: var t time.Time // Assume a millisecond unix timestamp if it's 13 digits -- too // large to be a reasonable timestamp in seconds. @@ -1086,7 +1092,7 @@ func (rc *SQLiteRows) Next(dest []driver.Value) error { s := C.GoStringN((*C.char)(unsafe.Pointer(C.sqlite3_column_text(rc.s.s, C.int(i)))), C.int(n)) switch rc.decltype[i] { - case "timestamp", "datetime", "date": + case columnTimestamp, columnDatetime, columnDate: var t time.Time s = strings.TrimSuffix(s, "Z") for _, format := range SQLiteTimestampFormats {