diff --git a/docs/howto/ddl.md b/docs/howto/ddl.md index f7c46aa3f5..936842312d 100644 --- a/docs/howto/ddl.md +++ b/docs/howto/ddl.md @@ -75,7 +75,7 @@ DROP TABLE people; package db type People struct { - ID int32 + ID int32 } ``` @@ -91,8 +91,8 @@ DROP TABLE comment; package db type Comment struct { - ID int32 - Text string + ID int32 + Text string } ``` diff --git a/docs/howto/named_parameters.md b/docs/howto/named_parameters.md index 1212549fac..f2af4352e9 100644 --- a/docs/howto/named_parameters.md +++ b/docs/howto/named_parameters.md @@ -17,8 +17,8 @@ RETURNING *; ```go type UpdateAuthorNameParams struct { - Column1 bool `json:""` - Column2_2 string `json:"_2"` + Column1 bool `json:""` + Column2_2 string `json:"_2"` } ``` @@ -38,8 +38,8 @@ RETURNING *; ```go type UpdateAuthorNameParams struct { - SetName bool `json:"set_name"` - Name string `json:"name"` + SetName bool `json:"set_name"` + Name string `json:"name"` } ``` diff --git a/docs/howto/prepared_query.md b/docs/howto/prepared_query.md index 20b6b0ad79..9561a31a6b 100644 --- a/docs/howto/prepared_query.md +++ b/docs/howto/prepared_query.md @@ -43,7 +43,7 @@ func Prepare(ctx context.Context, db DBTX) (*Queries, error) { return &q, nil } -func (q *Queries) queryRow(ctx context.Context, stmt *sql.Stmt, query string, args ...interface{}) (*sql.Row) { +func (q *Queries) queryRow(ctx context.Context, stmt *sql.Stmt, query string, args ...interface{}) *sql.Row { switch { case stmt != nil && q.tx != nil: return q.tx.StmtContext(ctx, stmt).QueryRowContext(ctx, args...) diff --git a/docs/howto/query_count.md b/docs/howto/query_count.md index b9ff8d12d9..857d5f0530 100644 --- a/docs/howto/query_count.md +++ b/docs/howto/query_count.md @@ -54,8 +54,8 @@ ORDER BY 1 ` type CountAuthorsByTownRow struct { - Hometown string - Count int + Hometown string + Count int } func (q *Queries) CountAuthorsByTown(ctx context.Context) ([]CountAuthorsByTownRow, error) { diff --git a/docs/howto/select.md b/docs/howto/select.md index 5f23435d74..41c72c7885 100644 --- a/docs/howto/select.md +++ b/docs/howto/select.md @@ -72,10 +72,10 @@ WHERE id = $1 ` func (q *Queries) GetAuthor(ctx context.Context, id int) (Author, error) { - row := q.db.QueryRowContext(ctx, getAuthor, id) - var i Author - err := row.Scan(&i.ID, &i.Bio, &i.BirthYear) - return i, err + row := q.db.QueryRowContext(ctx, getAuthor, id) + var i Author + err := row.Scan(&i.ID, &i.Bio, &i.BirthYear) + return i, err } const listAuthors = `-- name: ListAuthors :many @@ -84,26 +84,26 @@ ORDER BY id ` func (q *Queries) ListAuthors(ctx context.Context) ([]Author, error) { - rows, err := q.db.QueryContext(ctx, listAuthors) - if err != nil { - return nil, err - } - defer rows.Close() - var items []Author - for rows.Next() { - var i Author - if err := rows.Scan(&i.ID, &i.Bio, &i.BirthYear); err != nil { - return nil, err - } - items = append(items, i) - } - if err := rows.Close(); err != nil { - return nil, err - } - if err := rows.Err(); err != nil { - return nil, err - } - return items, nil + rows, err := q.db.QueryContext(ctx, listAuthors) + if err != nil { + return nil, err + } + defer rows.Close() + var items []Author + for rows.Next() { + var i Author + if err := rows.Scan(&i.ID, &i.Bio, &i.BirthYear); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Close(); err != nil { + return nil, err + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil } ``` @@ -212,7 +212,7 @@ import ( "context" "database/sql" - "github.com/lib/pq" + "github.com/lib/pq" ) type Author struct { @@ -240,25 +240,25 @@ WHERE id = ANY($1::int[]) ` func (q *Queries) ListAuthorsByIDs(ctx context.Context, ids []int) ([]Author, error) { - rows, err := q.db.QueryContext(ctx, listAuthors, pq.Array(ids)) - if err != nil { - return nil, err - } - defer rows.Close() - var items []Author - for rows.Next() { - var i Author - if err := rows.Scan(&i.ID, &i.Bio, &i.BirthYear); err != nil { - return nil, err - } - items = append(items, i) - } - if err := rows.Close(); err != nil { - return nil, err - } - if err := rows.Err(); err != nil { - return nil, err - } - return items, nil + rows, err := q.db.QueryContext(ctx, listAuthors, pq.Array(ids)) + if err != nil { + return nil, err + } + defer rows.Close() + var items []Author + for rows.Next() { + var i Author + if err := rows.Scan(&i.ID, &i.Bio, &i.BirthYear); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Close(); err != nil { + return nil, err + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil } ``` diff --git a/docs/reference/datatypes.md b/docs/reference/datatypes.md index 052cfc63a0..b035bd6865 100644 --- a/docs/reference/datatypes.md +++ b/docs/reference/datatypes.md @@ -39,8 +39,8 @@ CREATE TABLE authors ( package db import ( - "time" "database/sql" + "time" ) type Author struct { @@ -129,6 +129,6 @@ import ( ) type Author struct { - ID uuid.UUID + ID uuid.UUID } ``` diff --git a/docs/reference/query-annotations.md b/docs/reference/query-annotations.md index c16bb03a18..15d2128cd0 100644 --- a/docs/reference/query-annotations.md +++ b/docs/reference/query-annotations.md @@ -20,8 +20,8 @@ WHERE id = $1; ```go func (q *Queries) DeleteAuthor(ctx context.Context, id int64) error { - _, err := q.db.ExecContext(ctx, deleteAuthor, id) - return err + _, err := q.db.ExecContext(ctx, deleteAuthor, id) + return err } ``` @@ -37,7 +37,7 @@ DELETE FROM authors; ```go func (q *Queries) DeleteAllAuthors(ctx context.Context) (sql.Result, error) { - return q.db.ExecContext(ctx, deleteAllAuthors) + return q.db.ExecContext(ctx, deleteAllAuthors) } ``` @@ -54,8 +54,8 @@ DELETE FROM authors; ```go func (q *Queries) DeleteAllAuthors(ctx context.Context) (int64, error) { - _, err := q.db.ExecContext(ctx, deleteAllAuthors) - // ... + _, err := q.db.ExecContext(ctx, deleteAllAuthors) + // ... } ``` @@ -72,8 +72,8 @@ ORDER BY name; ```go func (q *Queries) ListAuthors(ctx context.Context) ([]Author, error) { - rows, err := q.db.QueryContext(ctx, listAuthors) - // ... + rows, err := q.db.QueryContext(ctx, listAuthors) + // ... } ``` @@ -90,7 +90,7 @@ WHERE id = $1 LIMIT 1; ```go func (q *Queries) GetAuthor(ctx context.Context, id int64) (Author, error) { - row := q.db.QueryRowContext(ctx, getAuthor, id) - // ... + row := q.db.QueryRowContext(ctx, getAuthor, id) + // ... } ```