From 46cc7603d4d7cc0e018b0abf2aacf1f9366c510f Mon Sep 17 00:00:00 2001 From: Brandon Philips Date: Sun, 8 Jun 2014 11:01:07 -0700 Subject: [PATCH 1/2] registry: remove unneeded time.Duration() These constants don't need to use time.Duration(). Fixup this file since it seems to be the only one using this style. Docker-DCO-1.1-Signed-off-by: Brandon Philips (github: philips) --- docs/registry.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/registry.go b/docs/registry.go index e91e7d12..24c55125 100644 --- a/docs/registry.go +++ b/docs/registry.go @@ -37,12 +37,12 @@ func pingRegistryEndpoint(endpoint string) (RegistryInfo, error) { } httpDial := func(proto string, addr string) (net.Conn, error) { // Set the connect timeout to 5 seconds - conn, err := net.DialTimeout(proto, addr, time.Duration(5)*time.Second) + conn, err := net.DialTimeout(proto, addr, 5*time.Second) if err != nil { return nil, err } // Set the recv timeout to 10 seconds - conn.SetDeadline(time.Now().Add(time.Duration(10) * time.Second)) + conn.SetDeadline(time.Now().Add(10 * time.Second)) return conn, nil } httpTransport := &http.Transport{ @@ -801,7 +801,7 @@ func NewRegistry(authConfig *AuthConfig, factory *utils.HTTPRequestFactory, inde if err != nil { return nil, err } - conn = utils.NewTimeoutConn(conn, time.Duration(1)*time.Minute) + conn = utils.NewTimeoutConn(conn, 1*time.Minute) return conn, nil } } From 7cd8de1329d3f893c140c04443467026df54b3e3 Mon Sep 17 00:00:00 2001 From: LK4D4 Date: Thu, 12 Jun 2014 09:15:53 +0400 Subject: [PATCH 2/2] Fix go vet errors Docker-DCO-1.1-Signed-off-by: Alexandr Morozov (github: LK4D4) Docker-DCO-1.1-Signed-off-by: Victor Vieux (github: vieux) --- docs/registry_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/registry_test.go b/docs/registry_test.go index 2aae80ed..5cec0595 100644 --- a/docs/registry_test.go +++ b/docs/registry_test.go @@ -264,7 +264,7 @@ func TestAddRequiredHeadersToRedirectedRequests(t *testing.T) { AddRequiredHeadersToRedirectedRequests(reqTo, []*http.Request{reqFrom}) if len(reqTo.Header) != 1 { - t.Fatal("Expected 1 headers, got %d", len(reqTo.Header)) + t.Fatalf("Expected 1 headers, got %d", len(reqTo.Header)) } if reqTo.Header.Get("Content-Type") != "application/json" { @@ -288,7 +288,7 @@ func TestAddRequiredHeadersToRedirectedRequests(t *testing.T) { AddRequiredHeadersToRedirectedRequests(reqTo, []*http.Request{reqFrom}) if len(reqTo.Header) != 2 { - t.Fatal("Expected 2 headers, got %d", len(reqTo.Header)) + t.Fatalf("Expected 2 headers, got %d", len(reqTo.Header)) } if reqTo.Header.Get("Content-Type") != "application/json" {