go fmt ./...

This commit is contained in:
Yasuhiro Matsumoto
2024-01-25 22:36:27 +09:00
committed by mattn
parent c91bca4fb4
commit 1f0dc0a0ef
49 changed files with 242 additions and 190 deletions

View File

@@ -3,6 +3,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build cgo
// +build cgo // +build cgo
package sqlite3 package sqlite3

View File

@@ -3,6 +3,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build cgo
// +build cgo // +build cgo
package sqlite3 package sqlite3

9
doc.go
View File

@@ -7,7 +7,7 @@ Installation
go get github.com/mattn/go-sqlite3 go get github.com/mattn/go-sqlite3
Supported Types # Supported Types
Currently, go-sqlite3 supports the following data types. Currently, go-sqlite3 supports the following data types.
@@ -24,7 +24,7 @@ Currently, go-sqlite3 supports the following data types.
|time.Time | timestamp/datetime| |time.Time | timestamp/datetime|
+------------------------------+ +------------------------------+
SQLite3 Extension # SQLite3 Extension
You can write your own extension module for sqlite3. For example, below is an You can write your own extension module for sqlite3. For example, below is an
extension for a Regexp matcher operation. extension for a Regexp matcher operation.
@@ -77,7 +77,7 @@ Then, you can use this extension.
rows, err := db.Query("select text from mytable where name regexp '^golang'") rows, err := db.Query("select text from mytable where name regexp '^golang'")
Connection Hook # Connection Hook
You can hook and inject your code when the connection is established by setting You can hook and inject your code when the connection is established by setting
ConnectHook to get the SQLiteConn. ConnectHook to get the SQLiteConn.
@@ -101,7 +101,7 @@ You can also use database/sql.Conn.Raw (Go >= 1.13):
}) })
// if err != nil { ... } // if err != nil { ... }
Go SQlite3 Extensions # Go SQlite3 Extensions
If you want to register Go functions as SQLite extension functions If you want to register Go functions as SQLite extension functions
you can make a custom driver by calling RegisterFunction from you can make a custom driver by calling RegisterFunction from
@@ -130,6 +130,5 @@ You can then use the custom driver by passing its name to sql.Open.
} }
See the documentation of RegisterFunc for more details. See the documentation of RegisterFunc for more details.
*/ */
package sqlite3 package sqlite3

View File

@@ -3,6 +3,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build cgo
// +build cgo // +build cgo
package sqlite3 package sqlite3

View File

@@ -975,10 +975,12 @@ func (c *SQLiteConn) begin(ctx context.Context) (driver.Tx, error) {
// The argument is may be either in parentheses or it may be separated from // The argument is may be either in parentheses or it may be separated from
// the pragma name by an equal sign. The two syntaxes yield identical results. // the pragma name by an equal sign. The two syntaxes yield identical results.
// In many pragmas, the argument is a boolean. The boolean can be one of: // In many pragmas, the argument is a boolean. The boolean can be one of:
//
// 1 yes true on // 1 yes true on
// 0 no false off // 0 no false off
// //
// You can specify a DSN string using a URI as the filename. // You can specify a DSN string using a URI as the filename.
//
// test.db // test.db
// file:test.db?cache=shared&mode=memory // file:test.db?cache=shared&mode=memory
// :memory: // :memory:
@@ -1010,6 +1012,7 @@ func (c *SQLiteConn) begin(ctx context.Context) (driver.Tx, error) {
// does in fact change can result in incorrect query results and/or SQLITE_CORRUPT errors. // does in fact change can result in incorrect query results and/or SQLITE_CORRUPT errors.
// //
// go-sqlite3 adds the following query parameters to those used by SQLite: // go-sqlite3 adds the following query parameters to those used by SQLite:
//
// _loc=XXX // _loc=XXX
// Specify location of time format. It's possible to specify "auto". // Specify location of time format. It's possible to specify "auto".
// //
@@ -1070,8 +1073,6 @@ func (c *SQLiteConn) begin(ctx context.Context) (driver.Tx, error) {
// When this pragma is on, the SQLITE_MASTER tables in which database // When this pragma is on, the SQLITE_MASTER tables in which database
// can be changed using ordinary UPDATE, INSERT, and DELETE statements. // can be changed using ordinary UPDATE, INSERT, and DELETE statements.
// Warning: misuse of this pragma can easily result in a corrupt database file. // Warning: misuse of this pragma can easily result in a corrupt database file.
//
//
func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) { func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) {
if C.sqlite3_threadsafe() == 0 { if C.sqlite3_threadsafe() == 0 {
return nil, errors.New("sqlite library was not compiled for thread-safe operation") return nil, errors.New("sqlite library was not compiled for thread-safe operation")

View File

@@ -3,6 +3,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build go1.13 && cgo
// +build go1.13,cgo // +build go1.13,cgo
package sqlite3 package sqlite3

View File

@@ -3,8 +3,8 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// +build cgo //go:build cgo && go1.8
// +build go1.8 // +build cgo,go1.8
package sqlite3 package sqlite3

View File

@@ -3,6 +3,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build go1.8 && cgo
// +build go1.8,cgo // +build go1.8,cgo
package sqlite3 package sqlite3

View File

@@ -3,6 +3,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build libsqlite3
// +build libsqlite3 // +build libsqlite3
package sqlite3 package sqlite3

View File

@@ -3,6 +3,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !sqlite_omit_load_extension
// +build !sqlite_omit_load_extension // +build !sqlite_omit_load_extension
package sqlite3 package sqlite3

View File

@@ -3,6 +3,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build sqlite_omit_load_extension
// +build sqlite_omit_load_extension // +build sqlite_omit_load_extension
package sqlite3 package sqlite3

View File

@@ -3,6 +3,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !sqlite_omit_load_extension
// +build !sqlite_omit_load_extension // +build !sqlite_omit_load_extension
package sqlite3 package sqlite3

View File

@@ -4,6 +4,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build sqlite_allow_uri_authority
// +build sqlite_allow_uri_authority // +build sqlite_allow_uri_authority
package sqlite3 package sqlite3

View File

@@ -4,8 +4,8 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// +build !windows //go:build !windows && sqlite_app_armor
// +build sqlite_app_armor // +build !windows,sqlite_app_armor
package sqlite3 package sqlite3

View File

@@ -1,3 +1,4 @@
//go:build sqlite_column_metadata
// +build sqlite_column_metadata // +build sqlite_column_metadata
package sqlite3 package sqlite3

View File

@@ -1,3 +1,4 @@
//go:build sqlite_column_metadata
// +build sqlite_column_metadata // +build sqlite_column_metadata
package sqlite3 package sqlite3

View File

@@ -4,6 +4,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build sqlite_foreign_keys
// +build sqlite_foreign_keys // +build sqlite_foreign_keys
package sqlite3 package sqlite3

View File

@@ -3,6 +3,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build cgo
// +build cgo // +build cgo
package sqlite3 package sqlite3

View File

@@ -3,6 +3,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build sqlite_fts5 || fts5
// +build sqlite_fts5 fts5 // +build sqlite_fts5 fts5
package sqlite3 package sqlite3

View File

@@ -3,6 +3,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build sqlite_icu || icu
// +build sqlite_icu icu // +build sqlite_icu icu
package sqlite3 package sqlite3

View File

@@ -4,6 +4,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build sqlite_introspect
// +build sqlite_introspect // +build sqlite_introspect
package sqlite3 package sqlite3

View File

@@ -3,6 +3,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build sqlite_math_functions
// +build sqlite_math_functions // +build sqlite_math_functions
package sqlite3 package sqlite3

View File

@@ -1,3 +1,4 @@
//go:build sqlite_math_functions
// +build sqlite_math_functions // +build sqlite_math_functions
package sqlite3 package sqlite3

View File

@@ -4,6 +4,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build cgo
// +build cgo // +build cgo
package sqlite3 package sqlite3

View File

@@ -4,6 +4,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build sqlite_preupdate_hook
// +build sqlite_preupdate_hook // +build sqlite_preupdate_hook
package sqlite3 package sqlite3

View File

@@ -4,6 +4,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build sqlite_preupdate_hook
// +build sqlite_preupdate_hook // +build sqlite_preupdate_hook
package sqlite3 package sqlite3

View File

@@ -4,6 +4,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !sqlite_preupdate_hook && cgo
// +build !sqlite_preupdate_hook,cgo // +build !sqlite_preupdate_hook,cgo
package sqlite3 package sqlite3

View File

@@ -4,6 +4,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build sqlite_secure_delete
// +build sqlite_secure_delete // +build sqlite_secure_delete
package sqlite3 package sqlite3

View File

@@ -4,6 +4,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build sqlite_secure_delete_fast
// +build sqlite_secure_delete_fast // +build sqlite_secure_delete_fast
package sqlite3 package sqlite3

View File

@@ -1,3 +1,4 @@
//go:build !libsqlite3 || sqlite_serialize
// +build !libsqlite3 sqlite_serialize // +build !libsqlite3 sqlite_serialize
package sqlite3 package sqlite3

View File

@@ -1,3 +1,4 @@
//go:build libsqlite3 && !sqlite_serialize
// +build libsqlite3,!sqlite_serialize // +build libsqlite3,!sqlite_serialize
package sqlite3 package sqlite3

View File

@@ -1,3 +1,4 @@
//go:build !libsqlite3 || sqlite_serialize
// +build !libsqlite3 sqlite_serialize // +build !libsqlite3 sqlite_serialize
package sqlite3 package sqlite3

View File

@@ -4,6 +4,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build sqlite_stat4
// +build sqlite_stat4 // +build sqlite_stat4
package sqlite3 package sqlite3

View File

@@ -3,8 +3,8 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// +build cgo //go:build cgo && sqlite_unlock_notify
// +build sqlite_unlock_notify // +build cgo,sqlite_unlock_notify
package sqlite3 package sqlite3

View File

@@ -3,6 +3,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build sqlite_unlock_notify
// +build sqlite_unlock_notify // +build sqlite_unlock_notify
package sqlite3 package sqlite3

View File

@@ -3,6 +3,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build sqlite_userauth
// +build sqlite_userauth // +build sqlite_userauth
package sqlite3 package sqlite3
@@ -79,7 +80,7 @@ var (
// If a database contains the SQLITE_USER table, then the // If a database contains the SQLITE_USER table, then the
// call to Authenticate must be invoked with an // call to Authenticate must be invoked with an
// appropriate username and password prior to enable read and write // appropriate username and password prior to enable read and write
//access to the database. // access to the database.
// //
// Return SQLITE_OK on success or SQLITE_ERROR if the username/password // Return SQLITE_OK on success or SQLITE_ERROR if the username/password
// combination is incorrect or unknown. // combination is incorrect or unknown.
@@ -103,6 +104,7 @@ func (c *SQLiteConn) Authenticate(username, password string) error {
// It is however exported for usage within SQL by the user. // It is however exported for usage within SQL by the user.
// //
// Returns: // Returns:
//
// C.SQLITE_OK (0) // C.SQLITE_OK (0)
// C.SQLITE_ERROR (1) // C.SQLITE_ERROR (1)
// C.SQLITE_AUTH (23) // C.SQLITE_AUTH (23)
@@ -155,6 +157,7 @@ func (c *SQLiteConn) AuthUserAdd(username, password string, admin bool) error {
// It is however exported for usage within SQL by the user. // It is however exported for usage within SQL by the user.
// //
// Returns: // Returns:
//
// C.SQLITE_OK (0) // C.SQLITE_OK (0)
// C.SQLITE_ERROR (1) // C.SQLITE_ERROR (1)
// C.SQLITE_AUTH (23) // C.SQLITE_AUTH (23)
@@ -207,6 +210,7 @@ func (c *SQLiteConn) AuthUserChange(username, password string, admin bool) error
// It is however exported for usage within SQL by the user. // It is however exported for usage within SQL by the user.
// //
// Returns: // Returns:
//
// C.SQLITE_OK (0) // C.SQLITE_OK (0)
// C.SQLITE_ERROR (1) // C.SQLITE_ERROR (1)
// C.SQLITE_AUTH (23) // C.SQLITE_AUTH (23)
@@ -249,6 +253,7 @@ func (c *SQLiteConn) AuthUserDelete(username string) error {
// It is however exported for usage within SQL by the user. // It is however exported for usage within SQL by the user.
// //
// Returns: // Returns:
//
// C.SQLITE_OK (0) // C.SQLITE_OK (0)
// C.SQLITE_ERROR (1) // C.SQLITE_ERROR (1)
// C.SQLITE_AUTH (23) // C.SQLITE_AUTH (23)
@@ -280,6 +285,7 @@ func (c *SQLiteConn) AuthEnabled() (exists bool) {
// It is however exported for usage within SQL by the user. // It is however exported for usage within SQL by the user.
// //
// Returns: // Returns:
//
// 0 - Disabled // 0 - Disabled
// 1 - Enabled // 1 - Enabled
func (c *SQLiteConn) authEnabled() int { func (c *SQLiteConn) authEnabled() int {

View File

@@ -3,6 +3,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !sqlite_userauth
// +build !sqlite_userauth // +build !sqlite_userauth
package sqlite3 package sqlite3
@@ -17,7 +18,7 @@ import (
// If a database contains the SQLITE_USER table, then the // If a database contains the SQLITE_USER table, then the
// call to Authenticate must be invoked with an // call to Authenticate must be invoked with an
// appropriate username and password prior to enable read and write // appropriate username and password prior to enable read and write
//access to the database. // access to the database.
// //
// Return SQLITE_OK on success or SQLITE_ERROR if the username/password // Return SQLITE_OK on success or SQLITE_ERROR if the username/password
// combination is incorrect or unknown. // combination is incorrect or unknown.
@@ -34,6 +35,7 @@ func (c *SQLiteConn) Authenticate(username, password string) error {
// It is however exported for usage within SQL by the user. // It is however exported for usage within SQL by the user.
// //
// Returns: // Returns:
//
// C.SQLITE_OK (0) // C.SQLITE_OK (0)
// C.SQLITE_ERROR (1) // C.SQLITE_ERROR (1)
// C.SQLITE_AUTH (23) // C.SQLITE_AUTH (23)
@@ -65,6 +67,7 @@ func (c *SQLiteConn) AuthUserAdd(username, password string, admin bool) error {
// It is however exported for usage within SQL by the user. // It is however exported for usage within SQL by the user.
// //
// Returns: // Returns:
//
// C.SQLITE_OK (0) // C.SQLITE_OK (0)
// C.SQLITE_ERROR (1) // C.SQLITE_ERROR (1)
// C.SQLITE_AUTH (23) // C.SQLITE_AUTH (23)
@@ -96,6 +99,7 @@ func (c *SQLiteConn) AuthUserChange(username, password string, admin bool) error
// It is however exported for usage within SQL by the user. // It is however exported for usage within SQL by the user.
// //
// Returns: // Returns:
//
// C.SQLITE_OK (0) // C.SQLITE_OK (0)
// C.SQLITE_ERROR (1) // C.SQLITE_ERROR (1)
// C.SQLITE_AUTH (23) // C.SQLITE_AUTH (23)
@@ -122,6 +126,7 @@ func (c *SQLiteConn) AuthUserDelete(username string) error {
// It is however exported for usage within SQL by the user. // It is however exported for usage within SQL by the user.
// //
// Returns: // Returns:
//
// C.SQLITE_OK (0) // C.SQLITE_OK (0)
// C.SQLITE_ERROR (1) // C.SQLITE_ERROR (1)
// C.SQLITE_AUTH (23) // C.SQLITE_AUTH (23)
@@ -142,6 +147,7 @@ func (c *SQLiteConn) AuthEnabled() (exists bool) {
// It is however exported for usage within SQL by the user. // It is however exported for usage within SQL by the user.
// //
// Returns: // Returns:
//
// 0 - Disabled // 0 - Disabled
// 1 - Enabled // 1 - Enabled
func (c *SQLiteConn) authEnabled() int { func (c *SQLiteConn) authEnabled() int {

View File

@@ -3,6 +3,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build sqlite_userauth
// +build sqlite_userauth // +build sqlite_userauth
package sqlite3 package sqlite3

View File

@@ -4,6 +4,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build sqlite_vacuum_full
// +build sqlite_vacuum_full // +build sqlite_vacuum_full
package sqlite3 package sqlite3

View File

@@ -4,6 +4,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build sqlite_vacuum_incr
// +build sqlite_vacuum_incr // +build sqlite_vacuum_incr
package sqlite3 package sqlite3

View File

@@ -3,6 +3,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build sqlite_vtable || vtable
// +build sqlite_vtable vtable // +build sqlite_vtable vtable
package sqlite3 package sqlite3

View File

@@ -3,6 +3,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !windows
// +build !windows // +build !windows
package sqlite3 package sqlite3

View File

@@ -3,6 +3,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build solaris
// +build solaris // +build solaris
package sqlite3 package sqlite3

View File

@@ -1128,7 +1128,7 @@ func TestQueryer(t *testing.T) {
if err != nil { if err != nil {
t.Error("Failed to db.Query:", err) t.Error("Failed to db.Query:", err)
} }
if id != n + 1 { if id != n+1 {
t.Error("Failed to db.Query: not matched results") t.Error("Failed to db.Query: not matched results")
} }
n = n + 1 n = n + 1

View File

@@ -3,6 +3,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build sqlite_trace || trace
// +build sqlite_trace trace // +build sqlite_trace trace
package sqlite3 package sqlite3

View File

@@ -3,6 +3,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build cgo
// +build cgo // +build cgo
package sqlite3 package sqlite3

View File

@@ -3,6 +3,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build windows
// +build windows // +build windows
package sqlite3 package sqlite3

View File

@@ -3,6 +3,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !cgo
// +build !cgo // +build !cgo
package sqlite3 package sqlite3