Skip to content

Commit

Permalink
Remove deprecated ioutils pkg functions (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
VojtechVitek authored Aug 25, 2023
1 parent 45007cb commit c081f17
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 12 deletions.
9 changes: 4 additions & 5 deletions _examples/golang-basics/example.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions _examples/golang-imports/api.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions client.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func doJSONRequest(ctx context.Context, client HTTPClient, url string, in, out i
}

if resp.StatusCode != 200 {
respBody, err := ioutil.ReadAll(resp.Body)
respBody, err := io.ReadAll(resp.Body)
if err != nil {
return ErrorWithCause(ErrWebrpcBadResponse, fmt.Errorf("failed to read server error response body: %w", err))
}
Expand All @@ -148,7 +148,7 @@ func doJSONRequest(ctx context.Context, client HTTPClient, url string, in, out i
}

if out != nil {
respBody, err := ioutil.ReadAll(resp.Body)
respBody, err := io.ReadAll(resp.Body)
if err != nil {
return ErrorWithCause(ErrWebrpcBadResponse, fmt.Errorf("failed to read response body: %w", err))
}
Expand Down
2 changes: 1 addition & 1 deletion imports.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
{{- set $stdlibImports "context" "" -}}
{{- set $stdlibImports "errors" "" -}}
{{- set $stdlibImports "fmt" "" -}}
{{- set $stdlibImports "io/ioutil" "" -}}
{{- set $stdlibImports "net/http" "" -}}

{{- if eq $opts.json "stdlib" -}}
Expand All @@ -22,6 +21,7 @@

{{- if $opts.server }}
{{- set $stdlibImports "strings" "" -}}
{{- set $stdlibImports "io" "" -}}
{{- end -}}

{{- /* Import "time" if there's at least one timestamp. */ -}}
Expand Down
2 changes: 1 addition & 1 deletion server.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (s *{{$serviceName}}) serve{{ .Name | firstLetterToUpper }}JSON(ctx context
{{- end}}
}{}

reqBody, err := ioutil.ReadAll(r.Body)
reqBody, err := io.ReadAll(r.Body)
if err != nil {
err = ErrorWithCause(ErrWebrpcBadRequest, fmt.Errorf("failed to read request data: %w", err))
RespondWithError(w, err)
Expand Down

0 comments on commit c081f17

Please sign in to comment.