Skip to content

Commit 4e11cd5

Browse files
committed
Use any instead of interface{}
1 parent 0882148 commit 4e11cd5

File tree

10 files changed

+35
-35
lines changed

10 files changed

+35
-35
lines changed

client.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ func (c *Client) getServerAPIVersionString() (version string, err error) {
416416
if resp.StatusCode != http.StatusOK {
417417
return "", fmt.Errorf("received unexpected status %d while trying to retrieve the server version", resp.StatusCode)
418418
}
419-
var versionResponse map[string]interface{}
419+
var versionResponse map[string]any
420420
if err := json.NewDecoder(resp.Body).Decode(&versionResponse); err != nil {
421421
return "", err
422422
}
@@ -427,7 +427,7 @@ func (c *Client) getServerAPIVersionString() (version string, err error) {
427427
}
428428

429429
type doOptions struct {
430-
data interface{}
430+
data any
431431
forceJSON bool
432432
headers map[string]string
433433
context context.Context
@@ -710,7 +710,7 @@ type hijackOptions struct {
710710
in io.Reader
711711
stdout io.Writer
712712
stderr io.Writer
713-
data interface{}
713+
data any
714714
}
715715

716716
// CloseWaiter is an interface with methods for closing the underlying resource
@@ -873,7 +873,7 @@ func (c *Client) getURL(path string) string {
873873
return fmt.Sprintf("%s%s", urlStr, path)
874874
}
875875

876-
func (c *Client) getPath(basepath string, opts interface{}) (string, error) {
876+
func (c *Client) getPath(basepath string, opts any) (string, error) {
877877
queryStr, requiredAPIVersion := queryStringVersion(opts)
878878
return c.pathVersionCheck(basepath, queryStr, requiredAPIVersion)
879879
}
@@ -912,7 +912,7 @@ func (c *Client) getFakeNativeURL(path string) string {
912912
return fmt.Sprintf("%s%s", urlStr, path)
913913
}
914914

915-
func queryStringVersion(opts interface{}) (string, APIVersion) {
915+
func queryStringVersion(opts any) (string, APIVersion) {
916916
if opts == nil {
917917
return "", nil
918918
}
@@ -951,7 +951,7 @@ func queryStringVersion(opts interface{}) (string, APIVersion) {
951951
return items.Encode(), apiVersion
952952
}
953953

954-
func queryString(opts interface{}) string {
954+
func queryString(opts any) string {
955955
s, _ := queryStringVersion(opts)
956956
return s
957957
}

client_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ func TestQueryString(t *testing.T) {
365365
f32QueryString := fmt.Sprintf("w=%s&x=10&y=10.35", strconv.FormatFloat(float64(v), 'f', -1, 64))
366366
jsonPerson := url.QueryEscape(`{"Name":"gopher","age":4}`)
367367
tests := []struct {
368-
input interface{}
368+
input any
369369
want string
370370
wantAPI APIVersion
371371
}{

container_create_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func TestCreateContainerWithHostConfig(t *testing.T) {
9999
t.Fatal(err)
100100
}
101101
req := fakeRT.requests[0]
102-
var gotBody map[string]interface{}
102+
var gotBody map[string]any
103103
err = json.NewDecoder(req.Body).Decode(&gotBody)
104104
if err != nil {
105105
t.Fatal(err)

env.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func (env *Env) SetInt64(key string, value int64) {
7979
// GetJSON unmarshals the value of the provided key in the provided iface.
8080
//
8181
// iface is a value that can be provided to the json.Unmarshal function.
82-
func (env *Env) GetJSON(key string, iface interface{}) error {
82+
func (env *Env) GetJSON(key string, iface any) error {
8383
sval := env.Get(key)
8484
if sval == "" {
8585
return nil
@@ -89,7 +89,7 @@ func (env *Env) GetJSON(key string, iface interface{}) error {
8989

9090
// SetJSON marshals the given value to JSON format and stores it using the
9191
// provided key.
92-
func (env *Env) SetJSON(key string, value interface{}) error {
92+
func (env *Env) SetJSON(key string, value any) error {
9393
sval, err := json.Marshal(value)
9494
if err != nil {
9595
return err
@@ -131,7 +131,7 @@ func (env *Env) Set(key, value string) {
131131
//
132132
// If `src` cannot be decoded as a json dictionary, an error is returned.
133133
func (env *Env) Decode(src io.Reader) error {
134-
m := make(map[string]interface{})
134+
m := make(map[string]any)
135135
if err := json.NewDecoder(src).Decode(&m); err != nil {
136136
return err
137137
}
@@ -142,7 +142,7 @@ func (env *Env) Decode(src io.Reader) error {
142142
}
143143

144144
// SetAuto will try to define the Set* method to call based on the given value.
145-
func (env *Env) SetAuto(key string, value interface{}) {
145+
func (env *Env) SetAuto(key string, value any) {
146146
if fval, ok := value.(float64); ok {
147147
env.SetInt64(key, int64(fval))
148148
} else if sval, ok := value.(string); ok {

env_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ func TestSetAuto(t *testing.T) {
377377
t.Parallel()
378378
buf := bytes.NewBufferString("oi")
379379
tests := []struct {
380-
input interface{}
380+
input any
381381
expected string
382382
}{
383383
{10, "10"},

image.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ func (c *Client) PullImage(opts PullImageOptions, auth AuthConfiguration) error
328328
return c.createImage(&opts, headers, nil, opts.OutputStream, opts.RawJSONStream, opts.InactivityTimeout, opts.Context)
329329
}
330330

331-
func (c *Client) createImage(opts interface{}, headers map[string]string, in io.Reader, w io.Writer, rawJSONStream bool, timeout time.Duration, context context.Context) error {
331+
func (c *Client) createImage(opts any, headers map[string]string, in io.Reader, w io.Writer, rawJSONStream bool, timeout time.Duration, context context.Context) error {
332332
url, err := c.getPath("/images/create", opts)
333333
if err != nil {
334334
return err

network.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -113,20 +113,20 @@ func (c *Client) NetworkInfo(id string) (*Network, error) {
113113
//
114114
// See https://goo.gl/6GugX3 for more details.
115115
type CreateNetworkOptions struct {
116-
Name string `json:"Name" yaml:"Name" toml:"Name"`
117-
Driver string `json:"Driver" yaml:"Driver" toml:"Driver"`
118-
Scope string `json:"Scope" yaml:"Scope" toml:"Scope"`
119-
IPAM *IPAMOptions `json:"IPAM,omitempty" yaml:"IPAM" toml:"IPAM"`
120-
ConfigFrom *NetworkConfigFrom `json:"ConfigFrom,omitempty" yaml:"ConfigFrom" toml:"ConfigFrom"`
121-
Options map[string]interface{} `json:"Options" yaml:"Options" toml:"Options"`
122-
Labels map[string]string `json:"Labels" yaml:"Labels" toml:"Labels"`
123-
CheckDuplicate bool `json:"CheckDuplicate" yaml:"CheckDuplicate" toml:"CheckDuplicate"`
124-
Internal bool `json:"Internal" yaml:"Internal" toml:"Internal"`
125-
EnableIPv6 bool `json:"EnableIPv6" yaml:"EnableIPv6" toml:"EnableIPv6"`
126-
Attachable bool `json:"Attachable" yaml:"Attachable" toml:"Attachable"`
127-
ConfigOnly bool `json:"ConfigOnly" yaml:"ConfigOnly" toml:"ConfigOnly"`
128-
Ingress bool `json:"Ingress" yaml:"Ingress" toml:"Ingress"`
129-
Context context.Context `json:"-"`
116+
Name string `json:"Name" yaml:"Name" toml:"Name"`
117+
Driver string `json:"Driver" yaml:"Driver" toml:"Driver"`
118+
Scope string `json:"Scope" yaml:"Scope" toml:"Scope"`
119+
IPAM *IPAMOptions `json:"IPAM,omitempty" yaml:"IPAM" toml:"IPAM"`
120+
ConfigFrom *NetworkConfigFrom `json:"ConfigFrom,omitempty" yaml:"ConfigFrom" toml:"ConfigFrom"`
121+
Options map[string]any `json:"Options" yaml:"Options" toml:"Options"`
122+
Labels map[string]string `json:"Labels" yaml:"Labels" toml:"Labels"`
123+
CheckDuplicate bool `json:"CheckDuplicate" yaml:"CheckDuplicate" toml:"CheckDuplicate"`
124+
Internal bool `json:"Internal" yaml:"Internal" toml:"Internal"`
125+
EnableIPv6 bool `json:"EnableIPv6" yaml:"EnableIPv6" toml:"EnableIPv6"`
126+
Attachable bool `json:"Attachable" yaml:"Attachable" toml:"Attachable"`
127+
ConfigOnly bool `json:"ConfigOnly" yaml:"ConfigOnly" toml:"ConfigOnly"`
128+
Ingress bool `json:"Ingress" yaml:"Ingress" toml:"Ingress"`
129+
Context context.Context `json:"-"`
130130
}
131131

132132
// NetworkConfigFrom is used in network creation for specifying the source of a

testing/server.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,7 +1528,7 @@ func (s *DockerServer) infoDocker(w http.ResponseWriter, r *http.Request) {
15281528
})
15291529
}
15301530
}
1531-
envs := map[string]interface{}{
1531+
envs := map[string]any{
15321532
"ID": "AAAA:XXXX:0000:BBBB:AAAA:XXXX:0000:BBBB:AAAA:XXXX:0000:BBBB",
15331533
"Containers": len(s.containers),
15341534
"ContainersRunning": running,
@@ -1538,7 +1538,7 @@ func (s *DockerServer) infoDocker(w http.ResponseWriter, r *http.Request) {
15381538
"Driver": "aufs",
15391539
"DriverStatus": [][]string{},
15401540
"SystemStatus": nil,
1541-
"Plugins": map[string]interface{}{
1541+
"Plugins": map[string]any{
15421542
"Volume": []string{
15431543
"local",
15441544
},
@@ -1571,9 +1571,9 @@ func (s *DockerServer) infoDocker(w http.ResponseWriter, r *http.Request) {
15711571
"OSType": "linux",
15721572
"Architecture": "x86_64",
15731573
"IndexServerAddress": "https://index.docker.io/v1/",
1574-
"RegistryConfig": map[string]interface{}{
1574+
"RegistryConfig": map[string]any{
15751575
"InsecureRegistryCIDRs": []string{},
1576-
"IndexConfigs": map[string]interface{}{},
1576+
"IndexConfigs": map[string]any{},
15771577
"Mirrors": nil,
15781578
},
15791579
"InitSha1": "e2042dbb0fcf49bb9da199186d9a5063cda92a01",
@@ -1597,7 +1597,7 @@ func (s *DockerServer) infoDocker(w http.ResponseWriter, r *http.Request) {
15971597
}
15981598

15991599
func (s *DockerServer) versionDocker(w http.ResponseWriter, r *http.Request) {
1600-
envs := map[string]interface{}{
1600+
envs := map[string]any{
16011601
"Version": "1.10.1",
16021602
"Os": "linux",
16031603
"KernelVersion": "3.13.0-77-generic",

testing/server_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2757,7 +2757,7 @@ func TestInfoDocker(t *testing.T) {
27572757
if recorder.Code != http.StatusOK {
27582758
t.Fatalf("InfoDocker: wrong status. Want %d. Got %d.", http.StatusOK, recorder.Code)
27592759
}
2760-
var infoData map[string]interface{}
2760+
var infoData map[string]any
27612761
err := json.Unmarshal(recorder.Body.Bytes(), &infoData)
27622762
if err != nil {
27632763
t.Fatal(err)

volume.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func (c *Client) ListVolumes(opts ListVolumesOptions) ([]Volume, error) {
5151
return nil, err
5252
}
5353
defer resp.Body.Close()
54-
m := make(map[string]interface{})
54+
m := make(map[string]any)
5555
if err = json.NewDecoder(resp.Body).Decode(&m); err != nil {
5656
return nil, err
5757
}

0 commit comments

Comments
 (0)