summaryrefslogtreecommitdiff
path: root/src/database
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2022-02-03 14:12:08 -0500
committerRuss Cox <rsc@golang.org>2022-04-11 16:34:30 +0000
commit19309779ac5e2f5a2fd3cbb34421dafb2855ac21 (patch)
tree67dfd3e5d96250325e383183f95b6f5fe1968514 /src/database
parent017933163ab6a2b254f0310c61b57db65cded92e (diff)
downloadgo-git-19309779ac5e2f5a2fd3cbb34421dafb2855ac21.tar.gz
all: gofmt main repo
[This CL is part of a sequence implementing the proposal #51082. The design doc is at https://go.dev/s/godocfmt-design.] Run the updated gofmt, which reformats doc comments, on the main repository. Vendored files are excluded. For #51082. Change-Id: I7332f099b60f716295fb34719c98c04eb1a85407 Reviewed-on: https://go-review.googlesource.com/c/go/+/384268 Reviewed-by: Jonathan Amsterdam <jba@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/database')
-rw-r--r--src/database/sql/driver/driver.go32
-rw-r--r--src/database/sql/driver/types.go30
-rw-r--r--src/database/sql/fakedb_test.go21
-rw-r--r--src/database/sql/sql.go82
4 files changed, 85 insertions, 80 deletions
diff --git a/src/database/sql/driver/driver.go b/src/database/sql/driver/driver.go
index 5342315d12..43fa579bda 100644
--- a/src/database/sql/driver/driver.go
+++ b/src/database/sql/driver/driver.go
@@ -47,12 +47,12 @@ import (
// It is either nil, a type handled by a database driver's NamedValueChecker
// interface, or an instance of one of these types:
//
-// int64
-// float64
-// bool
-// []byte
-// string
-// time.Time
+// int64
+// float64
+// bool
+// []byte
+// string
+// time.Time
//
// If the driver supports cursors, a returned Value may also implement the Rows interface
// in this package. This is used, for example, when a user selects a cursor
@@ -481,12 +481,13 @@ type RowsColumnTypeDatabaseTypeName interface {
// not a variable length type ok should return false.
// If length is not limited other than system limits, it should return math.MaxInt64.
// The following are examples of returned values for various types:
-// TEXT (math.MaxInt64, true)
-// varchar(10) (10, true)
-// nvarchar(10) (10, true)
-// decimal (0, false)
-// int (0, false)
-// bytea(30) (30, true)
+//
+// TEXT (math.MaxInt64, true)
+// varchar(10) (10, true)
+// nvarchar(10) (10, true)
+// decimal (0, false)
+// int (0, false)
+// bytea(30) (30, true)
type RowsColumnTypeLength interface {
Rows
ColumnTypeLength(index int) (length int64, ok bool)
@@ -504,9 +505,10 @@ type RowsColumnTypeNullable interface {
// RowsColumnTypePrecisionScale may be implemented by Rows. It should return
// the precision and scale for decimal types. If not applicable, ok should be false.
// The following are examples of returned values for various types:
-// decimal(38, 4) (38, 4, true)
-// int (0, 0, false)
-// decimal (math.MaxInt64, math.MaxInt64, true)
+//
+// decimal(38, 4) (38, 4, true)
+// int (0, 0, false)
+// decimal (math.MaxInt64, math.MaxInt64, true)
type RowsColumnTypePrecisionScale interface {
Rows
ColumnTypePrecisionScale(index int) (precision, scale int64, ok bool)
diff --git a/src/database/sql/driver/types.go b/src/database/sql/driver/types.go
index 506ce6c2cd..fa98df7acd 100644
--- a/src/database/sql/driver/types.go
+++ b/src/database/sql/driver/types.go
@@ -17,16 +17,16 @@ import (
// driver package to provide consistent implementations of conversions
// between drivers. The ValueConverters have several uses:
//
-// * converting from the Value types as provided by the sql package
-// into a database table's specific column type and making sure it
-// fits, such as making sure a particular int64 fits in a
-// table's uint16 column.
+// - converting from the Value types as provided by the sql package
+// into a database table's specific column type and making sure it
+// fits, such as making sure a particular int64 fits in a
+// table's uint16 column.
//
-// * converting a value as given from the database into one of the
-// driver Value types.
+// - converting a value as given from the database into one of the
+// driver Value types.
//
-// * by the sql package, for converting from a driver's Value type
-// to a user's type in a scan.
+// - by the sql package, for converting from a driver's Value type
+// to a user's type in a scan.
type ValueConverter interface {
// ConvertValue converts a value to a driver Value.
ConvertValue(v any) (Value, error)
@@ -45,13 +45,13 @@ type Valuer interface {
// Bool is a ValueConverter that converts input values to bools.
//
// The conversion rules are:
-// - booleans are returned unchanged
-// - for integer types,
-// 1 is true
-// 0 is false,
-// other integers are an error
-// - for strings and []byte, same rules as strconv.ParseBool
-// - all other types are an error
+// - booleans are returned unchanged
+// - for integer types,
+// 1 is true
+// 0 is false,
+// other integers are an error
+// - for strings and []byte, same rules as strconv.ParseBool
+// - all other types are an error
var Bool boolType
type boolType struct{}
diff --git a/src/database/sql/fakedb_test.go b/src/database/sql/fakedb_test.go
index d9b40ff53f..050aed1ec8 100644
--- a/src/database/sql/fakedb_test.go
+++ b/src/database/sql/fakedb_test.go
@@ -26,12 +26,12 @@ import (
// syntactically different and simpler than SQL. The syntax is as
// follows:
//
-// WIPE
-// CREATE|<tablename>|<col>=<type>,<col>=<type>,...
-// where types are: "string", [u]int{8,16,32,64}, "bool"
-// INSERT|<tablename>|col=val,col2=val2,col3=?
-// SELECT|<tablename>|projectcol1,projectcol2|filtercol=?,filtercol2=?
-// SELECT|<tablename>|projectcol1,projectcol2|filtercol=?param1,filtercol2=?param2
+// WIPE
+// CREATE|<tablename>|<col>=<type>,<col>=<type>,...
+// where types are: "string", [u]int{8,16,32,64}, "bool"
+// INSERT|<tablename>|col=val,col2=val2,col3=?
+// SELECT|<tablename>|projectcol1,projectcol2|filtercol=?,filtercol2=?
+// SELECT|<tablename>|projectcol1,projectcol2|filtercol=?param1,filtercol2=?param2
//
// Any of these can be preceded by PANIC|<method>|, to cause the
// named method on fakeStmt to panic.
@@ -250,10 +250,11 @@ func setHookOpenErr(fn func() error) {
}
// Supports dsn forms:
-// <dbname>
-// <dbname>;<opts> (only currently supported option is `badConn`,
-// which causes driver.ErrBadConn to be returned on
-// every other conn.Begin())
+//
+// <dbname>
+// <dbname>;<opts> (only currently supported option is `badConn`,
+// which causes driver.ErrBadConn to be returned on
+// every other conn.Begin())
func (d *fakeDriver) Open(dsn string) (driver.Conn, error) {
hookOpenErr.Lock()
fn := hookOpenErr.fn
diff --git a/src/database/sql/sql.go b/src/database/sql/sql.go
index 9a879464d8..f408a34234 100644
--- a/src/database/sql/sql.go
+++ b/src/database/sql/sql.go
@@ -99,14 +99,14 @@ type NamedArg struct {
//
// Example usage:
//
-// db.ExecContext(ctx, `
-// delete from Invoice
-// where
-// TimeCreated < @end
-// and TimeCreated >= @start;`,
-// sql.Named("start", startTime),
-// sql.Named("end", endTime),
-// )
+// db.ExecContext(ctx, `
+// delete from Invoice
+// where
+// TimeCreated < @end
+// and TimeCreated >= @start;`,
+// sql.Named("start", startTime),
+// sql.Named("end", endTime),
+// )
func Named(name string, value any) NamedArg {
// This method exists because the go1compat promise
// doesn't guarantee that structs don't grow more fields,
@@ -176,14 +176,14 @@ type RawBytes []byte
// NullString implements the Scanner interface so
// it can be used as a scan destination:
//
-// var s NullString
-// err := db.QueryRow("SELECT name FROM foo WHERE id=?", id).Scan(&s)
-// ...
-// if s.Valid {
-// // use s.String
-// } else {
-// // NULL value
-// }
+// var s NullString
+// err := db.QueryRow("SELECT name FROM foo WHERE id=?", id).Scan(&s)
+// ...
+// if s.Valid {
+// // use s.String
+// } else {
+// // NULL value
+// }
type NullString struct {
String string
Valid bool // Valid is true if String is not NULL
@@ -420,8 +420,8 @@ type Scanner interface {
//
// Example usage:
//
-// var outArg string
-// _, err := db.ExecContext(ctx, "ProcName", sql.Named("Arg1", sql.Out{Dest: &outArg}))
+// var outArg string
+// _, err := db.ExecContext(ctx, "ProcName", sql.Named("Arg1", sql.Out{Dest: &outArg}))
type Out struct {
_Named_Fields_Required struct{}
@@ -2378,11 +2378,12 @@ func (tx *Tx) Prepare(query string) (*Stmt, error) {
// an existing statement.
//
// Example:
-// updateMoney, err := db.Prepare("UPDATE balance SET money=money+? WHERE id=?")
-// ...
-// tx, err := db.Begin()
-// ...
-// res, err := tx.StmtContext(ctx, updateMoney).Exec(123.45, 98293203)
+//
+// updateMoney, err := db.Prepare("UPDATE balance SET money=money+? WHERE id=?")
+// ...
+// tx, err := db.Begin()
+// ...
+// res, err := tx.StmtContext(ctx, updateMoney).Exec(123.45, 98293203)
//
// The provided context is used for the preparation of the statement, not for the
// execution of the statement.
@@ -2465,11 +2466,12 @@ func (tx *Tx) StmtContext(ctx context.Context, stmt *Stmt) *Stmt {
// an existing statement.
//
// Example:
-// updateMoney, err := db.Prepare("UPDATE balance SET money=money+? WHERE id=?")
-// ...
-// tx, err := db.Begin()
-// ...
-// res, err := tx.Stmt(updateMoney).Exec(123.45, 98293203)
+//
+// updateMoney, err := db.Prepare("UPDATE balance SET money=money+? WHERE id=?")
+// ...
+// tx, err := db.Begin()
+// ...
+// res, err := tx.Stmt(updateMoney).Exec(123.45, 98293203)
//
// The returned statement operates within the transaction and will be closed
// when the transaction has been committed or rolled back.
@@ -2857,8 +2859,8 @@ func (s *Stmt) QueryRowContext(ctx context.Context, args ...any) *Row {
//
// Example usage:
//
-// var name string
-// err := nameByUseridStmt.QueryRow(id).Scan(&name)
+// var name string
+// err := nameByUseridStmt.QueryRow(id).Scan(&name)
//
// QueryRow uses context.Background internally; to specify the context, use
// QueryRowContext.
@@ -3209,16 +3211,16 @@ func rowsColumnInfoSetupConnLocked(rowsi driver.Rows) []*ColumnType {
// Scan converts columns read from the database into the following
// common Go types and special types provided by the sql package:
//
-// *string
-// *[]byte
-// *int, *int8, *int16, *int32, *int64
-// *uint, *uint8, *uint16, *uint32, *uint64
-// *bool
-// *float32, *float64
-// *interface{}
-// *RawBytes
-// *Rows (cursor value)
-// any type implementing Scanner (see Scanner docs)
+// *string
+// *[]byte
+// *int, *int8, *int16, *int32, *int64
+// *uint, *uint8, *uint16, *uint32, *uint64
+// *bool
+// *float32, *float64
+// *interface{}
+// *RawBytes
+// *Rows (cursor value)
+// any type implementing Scanner (see Scanner docs)
//
// In the most simple case, if the type of the value from the source
// column is an integer, bool or string type T and dest is of type *T,