Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: apply gofmt to sample code #1261

Merged
merged 1 commit into from
Nov 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/howto/ddl.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ DROP TABLE people;
package db

type People struct {
ID int32
ID int32
}
```

Expand All @@ -91,8 +91,8 @@ DROP TABLE comment;
package db

type Comment struct {
ID int32
Text string
ID int32
Text string
}
```

Expand Down
8 changes: 4 additions & 4 deletions docs/howto/named_parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
```

Expand All @@ -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"`
}
```

Expand Down
2 changes: 1 addition & 1 deletion docs/howto/prepared_query.md
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
Expand Down
4 changes: 2 additions & 2 deletions docs/howto/query_count.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
90 changes: 45 additions & 45 deletions docs/howto/select.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
```

Expand Down Expand Up @@ -212,7 +212,7 @@ import (
"context"
"database/sql"

"github.com/lib/pq"
"github.com/lib/pq"
)

type Author struct {
Expand Down Expand Up @@ -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
}
```
4 changes: 2 additions & 2 deletions docs/reference/datatypes.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ CREATE TABLE authors (
package db

import (
"time"
"database/sql"
"time"
)

type Author struct {
Expand Down Expand Up @@ -129,6 +129,6 @@ import (
)

type Author struct {
ID uuid.UUID
ID uuid.UUID
}
```
18 changes: 9 additions & 9 deletions docs/reference/query-annotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
```

Expand All @@ -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)
}
```

Expand All @@ -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)
// ...
}
```

Expand All @@ -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)
// ...
}
```

Expand All @@ -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)
// ...
}
```