Skip to content

Commit 9fef4d8

Browse files
authored
chore(relint): relint examples (#462)
Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
1 parent acb8b1c commit 9fef4d8

4 files changed

Lines changed: 15 additions & 4 deletions

File tree

docs/examples/auth/oauth2/main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,11 @@ func wireOauth2AccessCode() {
127127
func(params any) (any, error) {
128128
// The bound params struct exposes the raw HTTP request through HTTPRequest.
129129
// Untyped: extract from params; typed: it's already a field.
130-
r := params.(getCallbackParams).HTTPRequest
130+
callbackParams, ok := params.(getCallbackParams)
131+
if !ok {
132+
panic("internal error")
133+
}
134+
r := callbackParams.HTTPRequest
131135
if r.URL.Query().Get("state") != state {
132136
return nil, errors.New(http.StatusBadRequest, "state mismatch")
133137
}

docs/examples/auth/oauth2/oauth2

10.5 MB
Binary file not shown.

docs/examples/client/requests/main.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ func main() {
6464
func submitVariants() {
6565
// snippet:submitVariants
6666
// legacy — cached context, hard to cancel from the call site
67-
result, err := rt.Submit(op) //nolint:ineffassign,wastedassign,staticcheck // doc example: shows legacy form alongside preferred form
67+
result, err := rt.Submit(op)
68+
use(result, err)
6869

6970
// preferred — explicit context
7071
ctx, cancel := context.WithTimeout(parent, exampleTimeout)
@@ -97,7 +98,8 @@ func migrationForm() {
9798
// snippet:migrationForm
9899
// before
99100
op.Context = ctx
100-
result, err := rt.Submit(op) //nolint:ineffassign,wastedassign,staticcheck // doc example: shows before/after migration
101+
result, err := rt.Submit(op)
102+
use(result, err)
101103

102104
// after
103105
result, err = rt.SubmitContext(ctx, op)

docs/examples/contenttypes/streamingbodies/main.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ package main
1212

1313
import (
1414
"context"
15+
"errors"
1516
"io"
1617
"log"
1718
"net/http"
@@ -132,7 +133,11 @@ func serverUpload() {
132133
// snippet:serverUpload
133134
api.RegisterOperation("post", "/backups", runtime.OperationHandlerFunc(
134135
func(params any) (any, error) {
135-
body := params.(putBackupParams).Blob // io.ReadCloser
136+
putBackupParams, ok := params.(putBackupParams)
137+
if !ok {
138+
return nil, errors.New("invalid params")
139+
}
140+
body := putBackupParams.Blob // io.ReadCloser
136141
defer body.Close()
137142

138143
f, err := os.CreateTemp("", "upload-*")

0 commit comments

Comments
 (0)