Skip to content

Commit 708e763

Browse files
authored
docs: fix examples (#1608)
* chore: fix a compile error * style: apply gofmt to sample code
1 parent 90e4382 commit 708e763

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

docs/howto/insert.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,11 @@ INSERT INTO authors (name, bio) VALUES ($1, $2);
154154

155155
```go
156156
type CreateAuthorsParams struct {
157-
Name string
158-
Bio string
157+
Name string
158+
Bio string
159159
}
160160

161161
func (q *Queries) CreateAuthors(ctx context.Context, arg []CreateAuthorsParams) (int64, error) {
162-
return q.db.CopyFrom(ctx, []string{"authors"}, []string{"name", "bio"}, &iteratorForCreateAuthors{rows: arg})
162+
return q.db.CopyFrom(ctx, []string{"authors"}, []string{"name", "bio"}, &iteratorForCreateAuthors{rows: arg})
163163
}
164164
```

docs/howto/transactions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func (q *Queries) GetRecord(ctx context.Context, id int) (Record, error) {
5858
With pgx you'd use it like this for example:
5959

6060
```go
61-
function bumpCounter(ctx context.Context, p *pgx.Conn, id int) error {
61+
func bumpCounter(ctx context.Context, p *pgx.Conn, id int) error {
6262
tx, err := db.Begin(ctx)
6363
if err != nil {
6464
return err
@@ -71,7 +71,7 @@ function bumpCounter(ctx context.Context, p *pgx.Conn, id int) error {
7171
}
7272
if err := q.UpdateRecord(ctx, db.UpdateRecordParams{
7373
ID: r.ID,
74-
Counter: r.Counter+1,
74+
Counter: r.Counter + 1,
7575
}); err != nil {
7676
return err
7777
}

docs/reference/query-annotations.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,10 @@ WHERE book_id = $1;
130130

131131
```go
132132
type DeleteBookBatchResults struct {
133-
br pgx.BatchResults
133+
br pgx.BatchResults
134134
ind int
135135
}
136+
136137
func (q *Queries) DeleteBook(ctx context.Context, bookID []int32) *DeleteBookBatchResults {
137138
//...
138139
}
@@ -161,13 +162,14 @@ WHERE title = $1 AND year = $2;
161162

162163
```go
163164
type BooksByTitleYearBatchResults struct {
164-
br pgx.BatchResults
165+
br pgx.BatchResults
165166
ind int
166167
}
167168
type BooksByTitleYearParams struct {
168169
Title string `json:"title"`
169170
Year int32 `json:"year"`
170171
}
172+
171173
func (q *Queries) BooksByTitleYear(ctx context.Context, arg []BooksByTitleYearParams) *BooksByTitleYearBatchResults {
172174
//...
173175
}
@@ -202,13 +204,14 @@ RETURNING book_id, author_id, isbn
202204

203205
```go
204206
type CreateBookBatchResults struct {
205-
br pgx.BatchResults
207+
br pgx.BatchResults
206208
ind int
207209
}
208210
type CreateBookParams struct {
209-
AuthorID int32 `json:"author_id"`
210-
Isbn string `json:"isbn"`
211+
AuthorID int32 `json:"author_id"`
212+
Isbn string `json:"isbn"`
211213
}
214+
212215
func (q *Queries) CreateBook(ctx context.Context, arg []CreateBookParams) *CreateBookBatchResults {
213216
//...
214217
}

0 commit comments

Comments
 (0)