diff --git a/adapter/cockroachdb/connection.go b/adapter/cockroachdb/connection.go index 04ba8af6..bfab6af6 100644 --- a/adapter/cockroachdb/connection.go +++ b/adapter/cockroachdb/connection.go @@ -75,14 +75,14 @@ func (vs values) Isset(k string) bool { // // You can use a ConnectionURL struct as an argument for Open: // -// var settings = cockroachdb.ConnectionURL{ -// Host: "localhost", // Database server IP or host name. -// Database: "peanuts", // Database name. -// User: "cbrown", // Optional user name. -// Password: "snoopy", // Optional user password. -// } +// var settings = cockroachdb.ConnectionURL{ +// Host: "localhost", // Database server IP or host name. +// Database: "peanuts", // Database name. +// User: "cbrown", // Optional user name. +// Password: "snoopy", // Optional user password. +// } // -// sess, err = cockroachdb.Open(settings) +// sess, err = cockroachdb.Open(settings) // // If you already have a valid DSN, you can use ParseURL to convert it into // a ConnectionURL before passing it to Open. diff --git a/adapter/cockroachdb/custom_types_pgx.go b/adapter/cockroachdb/custom_types_pgx.go index 42be2a54..2d969580 100644 --- a/adapter/cockroachdb/custom_types_pgx.go +++ b/adapter/cockroachdb/custom_types_pgx.go @@ -1,3 +1,4 @@ +//go:build !pq // +build !pq // Copyright (c) 2012-present The upper.io/db authors. All rights reserved. diff --git a/adapter/cockroachdb/custom_types_pq.go b/adapter/cockroachdb/custom_types_pq.go index f843e95f..92cdd7b3 100644 --- a/adapter/cockroachdb/custom_types_pq.go +++ b/adapter/cockroachdb/custom_types_pq.go @@ -1,3 +1,4 @@ +//go:build pq // +build pq // Copyright (c) 2012-present The upper.io/db authors. All rights reserved. diff --git a/adapter/cockroachdb/database_pgx.go b/adapter/cockroachdb/database_pgx.go index ccf5faad..102a1f5f 100644 --- a/adapter/cockroachdb/database_pgx.go +++ b/adapter/cockroachdb/database_pgx.go @@ -28,10 +28,11 @@ import ( "context" "database/sql" + "time" + _ "github.com/jackc/pgx/v4/stdlib" "github.com/upper/db/v4" "github.com/upper/db/v4/internal/sqladapter" - "time" ) func (*database) OpenDSN(sess sqladapter.Session, dsn string) (*sql.DB, error) { diff --git a/adapter/cockroachdb/database_pq.go b/adapter/cockroachdb/database_pq.go index 11fa3499..ea42c061 100644 --- a/adapter/cockroachdb/database_pq.go +++ b/adapter/cockroachdb/database_pq.go @@ -27,9 +27,11 @@ package cockroachdb import ( "context" "database/sql" + "time" + _ "github.com/lib/pq" + db "github.com/upper/db/v4" "github.com/upper/db/v4/internal/sqladapter" - "time" ) func (*database) OpenDSN(sess sqladapter.Session, dsn string) (*sql.DB, error) { diff --git a/adapter/mysql/custom_types.go b/adapter/mysql/custom_types.go index 4b78aff4..13f22801 100644 --- a/adapter/mysql/custom_types.go +++ b/adapter/mysql/custom_types.go @@ -149,12 +149,12 @@ func DecodeJSON(dst interface{}, src interface{}) error { // // Example: // -// type MyCustomStruct struct { -// ID int64 `db:"id" json:"id"` -// Name string `db:"name" json:"name"` -// ... -// mysql.JSONConverter -// } +// type MyCustomStruct struct { +// ID int64 `db:"id" json:"id"` +// Name string `db:"name" json:"name"` +// ... +// mysql.JSONConverter +// } type JSONConverter struct{} func (*JSONConverter) ConvertValue(in interface{}) interface { diff --git a/adapter/postgresql/connection.go b/adapter/postgresql/connection.go index 47699442..ee7a7cd7 100644 --- a/adapter/postgresql/connection.go +++ b/adapter/postgresql/connection.go @@ -77,14 +77,14 @@ func (vs values) Isset(k string) bool { // // You can use a ConnectionURL struct as an argument for Open: // -// var settings = postgresql.ConnectionURL{ -// Host: "localhost", // PostgreSQL server IP or name. -// Database: "peanuts", // Database name. -// User: "cbrown", // Optional user name. -// Password: "snoopy", // Optional user password. -// } +// var settings = postgresql.ConnectionURL{ +// Host: "localhost", // PostgreSQL server IP or name. +// Database: "peanuts", // Database name. +// User: "cbrown", // Optional user name. +// Password: "snoopy", // Optional user password. +// } // -// sess, err = postgresql.Open(settings) +// sess, err = postgresql.Open(settings) // // If you already have a valid DSN, you can use ParseURL to convert it into // a ConnectionURL before passing it to Open. @@ -104,7 +104,7 @@ var escaper = strings.NewReplacer(` `, `\ `, `'`, `\'`, `\`, `\\`) // ParseURL parses the given DSN into a ConnectionURL struct. // A typical PostgreSQL connection URL looks like: // -// postgres://bob:secret@1.2.3.4:5432/mydb?sslmode=verify-full +// postgres://bob:secret@1.2.3.4:5432/mydb?sslmode=verify-full func ParseURL(s string) (u *ConnectionURL, err error) { o := make(values) @@ -260,7 +260,7 @@ func newScanner(s string) *scanner { // // "postgres://" // -// This will be blank, causing driver.Open to use all of the defaults +// # This will be blank, causing driver.Open to use all of the defaults // // NOTE: vendored/copied from github.com/lib/pq func parseURL(uri string) (string, error) { diff --git a/adapter/postgresql/custom_types_pgx.go b/adapter/postgresql/custom_types_pgx.go index 3559e6bf..2a0b6583 100644 --- a/adapter/postgresql/custom_types_pgx.go +++ b/adapter/postgresql/custom_types_pgx.go @@ -1,3 +1,4 @@ +//go:build !pq // +build !pq // Copyright (c) 2012-present The upper.io/db authors. All rights reserved. diff --git a/adapter/postgresql/custom_types_pq.go b/adapter/postgresql/custom_types_pq.go index 20ef131a..0ffdeb3d 100644 --- a/adapter/postgresql/custom_types_pq.go +++ b/adapter/postgresql/custom_types_pq.go @@ -1,3 +1,4 @@ +//go:build pq // +build pq package postgresql diff --git a/adapter/postgresql/database_pgx.go b/adapter/postgresql/database_pgx.go index 9cc40c30..6d5a2f3b 100644 --- a/adapter/postgresql/database_pgx.go +++ b/adapter/postgresql/database_pgx.go @@ -27,10 +27,11 @@ package postgresql import ( "context" "database/sql" + "time" + _ "github.com/jackc/pgx/v4/stdlib" "github.com/upper/db/v4" "github.com/upper/db/v4/internal/sqladapter" - "time" ) func (*database) OpenDSN(sess sqladapter.Session, dsn string) (*sql.DB, error) { diff --git a/adapter/postgresql/database_pq.go b/adapter/postgresql/database_pq.go index 559315c5..2415f624 100644 --- a/adapter/postgresql/database_pq.go +++ b/adapter/postgresql/database_pq.go @@ -27,9 +27,11 @@ package postgresql import ( "context" "database/sql" + "time" + _ "github.com/lib/pq" + db "github.com/upper/db/v4" "github.com/upper/db/v4/internal/sqladapter" - "time" ) func (*database) OpenDSN(sess sqladapter.Session, dsn string) (*sql.DB, error) { diff --git a/adapter/ql/connection_test.go b/adapter/ql/connection_test.go index cd453e00..dfb5e2e4 100644 --- a/adapter/ql/connection_test.go +++ b/adapter/ql/connection_test.go @@ -22,9 +22,10 @@ package ql import ( - "github.com/stretchr/testify/assert" "path/filepath" "testing" + + "github.com/stretchr/testify/assert" ) func TestConnectionURL(t *testing.T) { diff --git a/cond.go b/cond.go index cd8c070f..5895ad52 100644 --- a/cond.go +++ b/cond.go @@ -43,20 +43,20 @@ type LogicalOperator = adapter.LogicalOperator // // Examples: // -// // Age equals 18. -// db.Cond{"age": 18} +// // Age equals 18. +// db.Cond{"age": 18} // -// // Age is greater than or equal to 18. -// db.Cond{"age >=": 18} +// // Age is greater than or equal to 18. +// db.Cond{"age >=": 18} // -// // id is any of the values 1, 2 or 3. -// db.Cond{"id IN": []{1, 2, 3}} +// // id is any of the values 1, 2 or 3. +// db.Cond{"id IN": []{1, 2, 3}} // -// // Age is lower than 18 (MongoDB syntax) -// db.Cond{"age $lt": 18} +// // Age is lower than 18 (MongoDB syntax) +// db.Cond{"age $lt": 18} // -// // age > 32 and age < 35 -// db.Cond{"age >": 32, "age <": 35} +// // age > 32 and age < 35 +// db.Cond{"age >": 32, "age <": 35} type Cond map[interface{}]interface{} // Empty returns false if there are no conditions. diff --git a/internal/sqladapter/compat/query.go b/internal/sqladapter/compat/query.go index 93cb8fcf..91297fba 100644 --- a/internal/sqladapter/compat/query.go +++ b/internal/sqladapter/compat/query.go @@ -1,3 +1,4 @@ +//go:build !go1.8 // +build !go1.8 package compat diff --git a/internal/sqladapter/compat/query_go18.go b/internal/sqladapter/compat/query_go18.go index a3abbaf8..fbe38905 100644 --- a/internal/sqladapter/compat/query_go18.go +++ b/internal/sqladapter/compat/query_go18.go @@ -1,3 +1,4 @@ +//go:build go1.8 // +build go1.8 package compat diff --git a/internal/sqladapter/exql/column_value.go b/internal/sqladapter/exql/column_value.go index 49296114..7ea7d2ba 100644 --- a/internal/sqladapter/exql/column_value.go +++ b/internal/sqladapter/exql/column_value.go @@ -1,8 +1,9 @@ package exql import ( - "github.com/upper/db/v4/internal/cache" "strings" + + "github.com/upper/db/v4/internal/cache" ) // ColumnValue represents a bundle between a column and a corresponding value. diff --git a/internal/sqladapter/exql/statement.go b/internal/sqladapter/exql/statement.go index 9b9fd480..5fa009bf 100644 --- a/internal/sqladapter/exql/statement.go +++ b/internal/sqladapter/exql/statement.go @@ -10,7 +10,7 @@ import ( var errUnknownTemplateType = errors.New("Unknown template type") -// represents different kinds of SQL statements. +// represents different kinds of SQL statements. type Statement struct { Type Table Fragment diff --git a/internal/sqlbuilder/fetch.go b/internal/sqlbuilder/fetch.go index fe35dd89..b7fedae5 100644 --- a/internal/sqlbuilder/fetch.go +++ b/internal/sqlbuilder/fetch.go @@ -26,6 +26,7 @@ import ( "database/sql" "database/sql/driver" + db "github.com/upper/db/v4" "github.com/upper/db/v4/internal/reflectx" ) diff --git a/sql.go b/sql.go index a4bc18b9..5aaa2bd4 100644 --- a/sql.go +++ b/sql.go @@ -33,12 +33,11 @@ import ( // pointer, if you want to build a query using variables you need to reassign // them, like this: // -// a = builder.Select("name").From("foo") // "a" is created +// a = builder.Select("name").From("foo") // "a" is created // -// a.Where(...) // No effect, the value returned from Where is ignored. -// -// a = a.Where(...) // "a" is reassigned and points to a different address. +// a.Where(...) // No effect, the value returned from Where is ignored. // +// a = a.Where(...) // "a" is reassigned and points to a different address. type SQL interface { // Select initializes and returns a Selector, it accepts column names as