Skip to content

Commit

Permalink
Use any instead of interface{}
Browse files Browse the repository at this point in the history
I meant to do this when Go 1.19 was released, but I got distracted. Now
Go 1.20 is around the corner, so let's get rolling with this.
  • Loading branch information
fsouza committed Jan 12, 2023
1 parent 92f2f54 commit c82b595
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions fakestorage/json_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
type jsonResponse struct {
status int
header http.Header
data interface{}
data any
errorMessage string
}

Expand All @@ -30,7 +30,7 @@ func jsonToHTTPHandler(h jsonHandler) http.HandlerFunc {
}

status := resp.getStatus()
var data interface{}
var data any
if status > 399 {
data = newErrorResponse(status, resp.getErrorMessage(status), nil)
} else {
Expand Down
10 changes: 5 additions & 5 deletions fakestorage/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ func formatTime(t time.Time) string {
}

type listResponse struct {
Kind string `json:"kind"`
Items []interface{} `json:"items"`
Prefixes []string `json:"prefixes,omitempty"`
Kind string `json:"kind"`
Items []any `json:"items"`
Prefixes []string `json:"prefixes,omitempty"`
}

func newListBucketsResponse(buckets []backend.Bucket, location string) listResponse {
resp := listResponse{
Kind: "storage#buckets",
Items: make([]interface{}, len(buckets)),
Items: make([]any, len(buckets)),
}
for i, bucket := range buckets {
resp.Items[i] = newBucketResponse(bucket, location)
Expand Down Expand Up @@ -63,7 +63,7 @@ func newBucketResponse(bucket backend.Bucket, location string) bucketResponse {
func newListObjectsResponse(objs []ObjectAttrs, prefixes []string) listResponse {
resp := listResponse{
Kind: "storage#objects",
Items: make([]interface{}, len(objs)),
Items: make([]any, len(objs)),
Prefixes: prefixes,
}
for i, obj := range objs {
Expand Down
4 changes: 2 additions & 2 deletions fakestorage/xml_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
type xmlResponse struct {
status int
header http.Header
data interface{}
data any
errorMessage string
}

Expand All @@ -25,7 +25,7 @@ func xmlToHTTPHandler(h xmlHandler) http.HandlerFunc {
}

status := resp.getStatus()
var data interface{}
var data any
if status > 399 {
data = newErrorResponse(status, resp.getErrorMessage(status), nil)
} else {
Expand Down

0 comments on commit c82b595

Please sign in to comment.