Browse code

client: Use string concatenation instead of Sprintf

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>

Aaron Lehmann authored on 2017/06/02 21:00:56
Showing 4 changed files
... ...
@@ -216,9 +216,9 @@ func (cli *Client) getAPIPath(p string, query url.Values) string {
216 216
 	var apiPath string
217 217
 	if cli.version != "" {
218 218
 		v := strings.TrimPrefix(cli.version, "v")
219
-		apiPath = fmt.Sprintf("%s/v%s%s", cli.basePath, v, p)
219
+		apiPath = cli.basePath + "/v" + v + p
220 220
 	} else {
221
-		apiPath = fmt.Sprintf("%s%s", cli.basePath, p)
221
+		apiPath = cli.basePath + p
222 222
 	}
223 223
 
224 224
 	u := &url.URL{
... ...
@@ -20,7 +20,7 @@ func (cli *Client) ContainerStatPath(ctx context.Context, containerID, path stri
20 20
 	query := url.Values{}
21 21
 	query.Set("path", filepath.ToSlash(path)) // Normalize the paths used in the API.
22 22
 
23
-	urlStr := fmt.Sprintf("/containers/%s/archive", containerID)
23
+	urlStr := "/containers/" + containerID + "/archive"
24 24
 	response, err := cli.head(ctx, urlStr, query, nil)
25 25
 	if err != nil {
26 26
 		return types.ContainerPathStat{}, err
... ...
@@ -42,7 +42,7 @@ func (cli *Client) CopyToContainer(ctx context.Context, container, path string,
42 42
 		query.Set("copyUIDGID", "true")
43 43
 	}
44 44
 
45
-	apiPath := fmt.Sprintf("/containers/%s/archive", container)
45
+	apiPath := "/containers/" + container + "/archive"
46 46
 
47 47
 	response, err := cli.putRaw(ctx, apiPath, query, content, nil)
48 48
 	if err != nil {
... ...
@@ -63,7 +63,7 @@ func (cli *Client) CopyFromContainer(ctx context.Context, container, srcPath str
63 63
 	query := make(url.Values, 1)
64 64
 	query.Set("path", filepath.ToSlash(srcPath)) // Normalize the paths used in the API.
65 65
 
66
-	apiPath := fmt.Sprintf("/containers/%s/archive", container)
66
+	apiPath := "/containers/" + container + "/archive"
67 67
 	response, err := cli.get(ctx, apiPath, query, nil)
68 68
 	if err != nil {
69 69
 		return nil, types.ContainerPathStat{}, err
... ...
@@ -1,8 +1,6 @@
1 1
 package client
2 2
 
3 3
 import (
4
-	"fmt"
5
-
6 4
 	"github.com/docker/docker/api/types"
7 5
 	"golang.org/x/net/context"
8 6
 )
... ...
@@ -10,7 +8,7 @@ import (
10 10
 // Ping pings the server and returns the value of the "Docker-Experimental", "OS-Type" & "API-Version" headers
11 11
 func (cli *Client) Ping(ctx context.Context) (types.Ping, error) {
12 12
 	var ping types.Ping
13
-	req, err := cli.buildRequest("GET", fmt.Sprintf("%s/_ping", cli.basePath), nil, nil)
13
+	req, err := cli.buildRequest("GET", cli.basePath+"/_ping", nil, nil)
14 14
 	if err != nil {
15 15
 		return ping, err
16 16
 	}
... ...
@@ -1,7 +1,6 @@
1 1
 package client
2 2
 
3 3
 import (
4
-	"fmt"
5 4
 	"io"
6 5
 	"net/url"
7 6
 
... ...
@@ -33,5 +32,5 @@ func (cli *Client) PluginUpgrade(ctx context.Context, name string, options types
33 33
 
34 34
 func (cli *Client) tryPluginUpgrade(ctx context.Context, query url.Values, privileges types.PluginPrivileges, name, registryAuth string) (serverResponse, error) {
35 35
 	headers := map[string][]string{"X-Registry-Auth": {registryAuth}}
36
-	return cli.post(ctx, fmt.Sprintf("/plugins/%s/upgrade", name), query, privileges, headers)
36
+	return cli.post(ctx, "/plugins/"+name+"/upgrade", query, privileges, headers)
37 37
 }