Skip to content

Commit db0e66a

Browse files
authored
style: apply gofmt to sample code (#1261)
1 parent 0d3508d commit db0e66a

File tree

7 files changed

+66
-66
lines changed

7 files changed

+66
-66
lines changed

docs/howto/ddl.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ DROP TABLE people;
7575
package db
7676

7777
type People struct {
78-
ID int32
78+
ID int32
7979
}
8080
```
8181

@@ -91,8 +91,8 @@ DROP TABLE comment;
9191
package db
9292

9393
type Comment struct {
94-
ID int32
95-
Text string
94+
ID int32
95+
Text string
9696
}
9797
```
9898

docs/howto/named_parameters.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ RETURNING *;
1717

1818
```go
1919
type UpdateAuthorNameParams struct {
20-
Column1 bool `json:""`
21-
Column2_2 string `json:"_2"`
20+
Column1 bool `json:""`
21+
Column2_2 string `json:"_2"`
2222
}
2323
```
2424

@@ -38,8 +38,8 @@ RETURNING *;
3838

3939
```go
4040
type UpdateAuthorNameParams struct {
41-
SetName bool `json:"set_name"`
42-
Name string `json:"name"`
41+
SetName bool `json:"set_name"`
42+
Name string `json:"name"`
4343
}
4444
```
4545

docs/howto/prepared_query.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func Prepare(ctx context.Context, db DBTX) (*Queries, error) {
4343
return &q, nil
4444
}
4545

46-
func (q *Queries) queryRow(ctx context.Context, stmt *sql.Stmt, query string, args ...interface{}) (*sql.Row) {
46+
func (q *Queries) queryRow(ctx context.Context, stmt *sql.Stmt, query string, args ...interface{}) *sql.Row {
4747
switch {
4848
case stmt != nil && q.tx != nil:
4949
return q.tx.StmtContext(ctx, stmt).QueryRowContext(ctx, args...)

docs/howto/query_count.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ ORDER BY 1
5454
`
5555

5656
type CountAuthorsByTownRow struct {
57-
Hometown string
58-
Count int
57+
Hometown string
58+
Count int
5959
}
6060

6161
func (q *Queries) CountAuthorsByTown(ctx context.Context) ([]CountAuthorsByTownRow, error) {

docs/howto/select.md

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ WHERE id = $1
7272
`
7373

7474
func (q *Queries) GetAuthor(ctx context.Context, id int) (Author, error) {
75-
row := q.db.QueryRowContext(ctx, getAuthor, id)
76-
var i Author
77-
err := row.Scan(&i.ID, &i.Bio, &i.BirthYear)
78-
return i, err
75+
row := q.db.QueryRowContext(ctx, getAuthor, id)
76+
var i Author
77+
err := row.Scan(&i.ID, &i.Bio, &i.BirthYear)
78+
return i, err
7979
}
8080

8181
const listAuthors = `-- name: ListAuthors :many
@@ -84,26 +84,26 @@ ORDER BY id
8484
`
8585

8686
func (q *Queries) ListAuthors(ctx context.Context) ([]Author, error) {
87-
rows, err := q.db.QueryContext(ctx, listAuthors)
88-
if err != nil {
89-
return nil, err
90-
}
91-
defer rows.Close()
92-
var items []Author
93-
for rows.Next() {
94-
var i Author
95-
if err := rows.Scan(&i.ID, &i.Bio, &i.BirthYear); err != nil {
96-
return nil, err
97-
}
98-
items = append(items, i)
99-
}
100-
if err := rows.Close(); err != nil {
101-
return nil, err
102-
}
103-
if err := rows.Err(); err != nil {
104-
return nil, err
105-
}
106-
return items, nil
87+
rows, err := q.db.QueryContext(ctx, listAuthors)
88+
if err != nil {
89+
return nil, err
90+
}
91+
defer rows.Close()
92+
var items []Author
93+
for rows.Next() {
94+
var i Author
95+
if err := rows.Scan(&i.ID, &i.Bio, &i.BirthYear); err != nil {
96+
return nil, err
97+
}
98+
items = append(items, i)
99+
}
100+
if err := rows.Close(); err != nil {
101+
return nil, err
102+
}
103+
if err := rows.Err(); err != nil {
104+
return nil, err
105+
}
106+
return items, nil
107107
}
108108
```
109109

@@ -212,7 +212,7 @@ import (
212212
"context"
213213
"database/sql"
214214

215-
"github.com/lib/pq"
215+
"github.com/lib/pq"
216216
)
217217

218218
type Author struct {
@@ -240,25 +240,25 @@ WHERE id = ANY($1::int[])
240240
`
241241

242242
func (q *Queries) ListAuthorsByIDs(ctx context.Context, ids []int) ([]Author, error) {
243-
rows, err := q.db.QueryContext(ctx, listAuthors, pq.Array(ids))
244-
if err != nil {
245-
return nil, err
246-
}
247-
defer rows.Close()
248-
var items []Author
249-
for rows.Next() {
250-
var i Author
251-
if err := rows.Scan(&i.ID, &i.Bio, &i.BirthYear); err != nil {
252-
return nil, err
253-
}
254-
items = append(items, i)
255-
}
256-
if err := rows.Close(); err != nil {
257-
return nil, err
258-
}
259-
if err := rows.Err(); err != nil {
260-
return nil, err
261-
}
262-
return items, nil
243+
rows, err := q.db.QueryContext(ctx, listAuthors, pq.Array(ids))
244+
if err != nil {
245+
return nil, err
246+
}
247+
defer rows.Close()
248+
var items []Author
249+
for rows.Next() {
250+
var i Author
251+
if err := rows.Scan(&i.ID, &i.Bio, &i.BirthYear); err != nil {
252+
return nil, err
253+
}
254+
items = append(items, i)
255+
}
256+
if err := rows.Close(); err != nil {
257+
return nil, err
258+
}
259+
if err := rows.Err(); err != nil {
260+
return nil, err
261+
}
262+
return items, nil
263263
}
264264
```

docs/reference/datatypes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ CREATE TABLE authors (
3939
package db
4040

4141
import (
42-
"time"
4342
"database/sql"
43+
"time"
4444
)
4545

4646
type Author struct {
@@ -129,6 +129,6 @@ import (
129129
)
130130

131131
type Author struct {
132-
ID uuid.UUID
132+
ID uuid.UUID
133133
}
134134
```

docs/reference/query-annotations.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ WHERE id = $1;
2020

2121
```go
2222
func (q *Queries) DeleteAuthor(ctx context.Context, id int64) error {
23-
_, err := q.db.ExecContext(ctx, deleteAuthor, id)
24-
return err
23+
_, err := q.db.ExecContext(ctx, deleteAuthor, id)
24+
return err
2525
}
2626
```
2727

@@ -37,7 +37,7 @@ DELETE FROM authors;
3737

3838
```go
3939
func (q *Queries) DeleteAllAuthors(ctx context.Context) (sql.Result, error) {
40-
return q.db.ExecContext(ctx, deleteAllAuthors)
40+
return q.db.ExecContext(ctx, deleteAllAuthors)
4141
}
4242
```
4343

@@ -54,8 +54,8 @@ DELETE FROM authors;
5454

5555
```go
5656
func (q *Queries) DeleteAllAuthors(ctx context.Context) (int64, error) {
57-
_, err := q.db.ExecContext(ctx, deleteAllAuthors)
58-
// ...
57+
_, err := q.db.ExecContext(ctx, deleteAllAuthors)
58+
// ...
5959
}
6060
```
6161

@@ -72,8 +72,8 @@ ORDER BY name;
7272

7373
```go
7474
func (q *Queries) ListAuthors(ctx context.Context) ([]Author, error) {
75-
rows, err := q.db.QueryContext(ctx, listAuthors)
76-
// ...
75+
rows, err := q.db.QueryContext(ctx, listAuthors)
76+
// ...
7777
}
7878
```
7979

@@ -90,7 +90,7 @@ WHERE id = $1 LIMIT 1;
9090

9191
```go
9292
func (q *Queries) GetAuthor(ctx context.Context, id int64) (Author, error) {
93-
row := q.db.QueryRowContext(ctx, getAuthor, id)
94-
// ...
93+
row := q.db.QueryRowContext(ctx, getAuthor, id)
94+
// ...
9595
}
9696
```

0 commit comments

Comments
 (0)