From 320c333f2b49acd698b49b73ed01d32da4d15c8c Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Mon, 13 Apr 2015 13:22:34 -0400 Subject: [PATCH] 5414: Fix up formatting. --- sdk/go/keepclient/keepclient.go | 14 +++++++------- sdk/go/keepclient/keepclient_test.go | 14 +++++++------- sdk/go/keepclient/root_sorter.go | 12 ++++++------ sdk/go/keepclient/root_sorter_test.go | 9 +++++---- 4 files changed, 25 insertions(+), 24 deletions(-) diff --git a/sdk/go/keepclient/keepclient.go b/sdk/go/keepclient/keepclient.go index 853f4c61ef..31cfb572e4 100644 --- a/sdk/go/keepclient/keepclient.go +++ b/sdk/go/keepclient/keepclient.go @@ -24,7 +24,7 @@ const BLOCKSIZE = 64 * 1024 * 1024 var BlockNotFound = errors.New("Block not found") var InsufficientReplicasError = errors.New("Could not write sufficient replicas") -var OversizeBlockError = errors.New("Exceeded maximum block size ("+strconv.Itoa(BLOCKSIZE)+")") +var OversizeBlockError = errors.New("Exceeded maximum block size (" + strconv.Itoa(BLOCKSIZE) + ")") var MissingArvadosApiHost = errors.New("Missing required environment variable ARVADOS_API_HOST") var MissingArvadosApiToken = errors.New("Missing required environment variable ARVADOS_API_TOKEN") var InvalidLocatorError = errors.New("Invalid locator") @@ -126,7 +126,7 @@ func (kc *KeepClient) PutR(r io.Reader) (locator string, replicas int, err error func (kc *KeepClient) Get(locator string) (io.ReadCloser, int64, string, error) { var errs []string for _, host := range kc.getSortedRoots(locator) { - url := host+"/"+locator + url := host + "/" + locator req, err := http.NewRequest("GET", url, nil) if err != nil { continue @@ -148,8 +148,8 @@ func (kc *KeepClient) Get(locator string) (io.ReadCloser, int64, string, error) } return HashCheckingReader{ Reader: resp.Body, - Hash: md5.New(), - Check: locator[0:32], + Hash: md5.New(), + Check: locator[0:32], }, resp.ContentLength, url, nil } log.Printf("DEBUG: GET %s failed: %v", locator, errs) @@ -165,7 +165,7 @@ func (kc *KeepClient) Get(locator string) (io.ReadCloser, int64, string, error) // and the URI reporting the data size. func (kc *KeepClient) Ask(locator string) (int64, string, error) { for _, host := range kc.getSortedRoots(locator) { - url := host+"/"+locator + url := host + "/" + locator req, err := http.NewRequest("HEAD", url, nil) if err != nil { continue @@ -246,8 +246,8 @@ func (kc *KeepClient) getSortedRoots(locator string) []string { type Locator struct { Hash string - Size int // -1 if data size is not known - Hints []string // Including the size hint, if any + Size int // -1 if data size is not known + Hints []string // Including the size hint, if any } func (loc *Locator) String() string { diff --git a/sdk/go/keepclient/keepclient_test.go b/sdk/go/keepclient/keepclient_test.go index 7054bbad91..5c8d2a031a 100644 --- a/sdk/go/keepclient/keepclient_test.go +++ b/sdk/go/keepclient/keepclient_test.go @@ -504,7 +504,7 @@ func (s *StandaloneSuite) TestGetWithServiceHint(c *C) { // This one should be used: ks := RunFakeKeepServer(StubGetHandler{ c, - hash+"+K@"+uuid, + hash + "+K@" + uuid, "abc123", http.StatusOK, []byte("foo")}) @@ -517,7 +517,7 @@ func (s *StandaloneSuite) TestGetWithServiceHint(c *C) { map[string]string{"x": ks0.url}, map[string]string{uuid: ks.url}) - r, n, uri, err := kc.Get(hash+"+K@"+uuid) + r, n, uri, err := kc.Get(hash + "+K@" + uuid) defer r.Close() c.Check(err, Equals, nil) c.Check(n, Equals, int64(3)) @@ -546,7 +546,7 @@ func (s *StandaloneSuite) TestGetWithLocalServiceHint(c *C) { // This one should be used: ks := RunFakeKeepServer(StubGetHandler{ c, - hash+"+K@"+uuid, + hash + "+K@" + uuid, "abc123", http.StatusOK, []byte("foo")}) @@ -568,7 +568,7 @@ func (s *StandaloneSuite) TestGetWithLocalServiceHint(c *C) { uuid: ks.url}, ) - r, n, uri, err := kc.Get(hash+"+K@"+uuid) + r, n, uri, err := kc.Get(hash + "+K@" + uuid) defer r.Close() c.Check(err, Equals, nil) c.Check(n, Equals, int64(3)) @@ -585,14 +585,14 @@ func (s *StandaloneSuite) TestGetWithServiceHintFailoverToLocals(c *C) { ksLocal := RunFakeKeepServer(StubGetHandler{ c, - hash+"+K@"+uuid, + hash + "+K@" + uuid, "abc123", http.StatusOK, []byte("foo")}) defer ksLocal.listener.Close() ksGateway := RunFakeKeepServer(StubGetHandler{ c, - hash+"+K@"+uuid, + hash + "+K@" + uuid, "abc123", http.StatusInternalServerError, []byte("Error")}) @@ -605,7 +605,7 @@ func (s *StandaloneSuite) TestGetWithServiceHintFailoverToLocals(c *C) { map[string]string{"zzzzz-bi6l4-keepdisk0000000": ksLocal.url}, map[string]string{uuid: ksGateway.url}) - r, n, uri, err := kc.Get(hash+"+K@"+uuid) + r, n, uri, err := kc.Get(hash + "+K@" + uuid) c.Assert(err, Equals, nil) defer r.Close() c.Check(n, Equals, int64(3)) diff --git a/sdk/go/keepclient/root_sorter.go b/sdk/go/keepclient/root_sorter.go index c2780bc716..a8afea0961 100644 --- a/sdk/go/keepclient/root_sorter.go +++ b/sdk/go/keepclient/root_sorter.go @@ -5,12 +5,12 @@ import ( ) type RootSorter struct { - root []string - weight []string - order []int + root []string + weight []string + order []int } -func NewRootSorter(serviceRoots map[string]string, hash string) (*RootSorter) { +func NewRootSorter(serviceRoots map[string]string, hash string) *RootSorter { rs := new(RootSorter) rs.root = make([]string, len(serviceRoots)) rs.weight = make([]string, len(serviceRoots)) @@ -26,7 +26,7 @@ func NewRootSorter(serviceRoots map[string]string, hash string) (*RootSorter) { return rs } -func (rs RootSorter) getWeight(hash string, uuid string) (string) { +func (rs RootSorter) getWeight(hash string, uuid string) string { if len(uuid) == 27 { return Md5String(hash + uuid[12:]) } else { @@ -35,7 +35,7 @@ func (rs RootSorter) getWeight(hash string, uuid string) (string) { } } -func (rs RootSorter) GetSortedRoots() ([]string) { +func (rs RootSorter) GetSortedRoots() []string { sorted := make([]string, len(rs.order)) for i := range rs.order { sorted[i] = rs.root[rs.order[i]] diff --git a/sdk/go/keepclient/root_sorter_test.go b/sdk/go/keepclient/root_sorter_test.go index 455715d427..23e8cc93f2 100644 --- a/sdk/go/keepclient/root_sorter_test.go +++ b/sdk/go/keepclient/root_sorter_test.go @@ -8,19 +8,20 @@ import ( ) type RootSorterSuite struct{} + var _ = Suite(&RootSorterSuite{}) -func FakeSvcRoot(i uint64) (string) { +func FakeSvcRoot(i uint64) string { return fmt.Sprintf("https://%x.svc/", i) } -func FakeSvcUuid(i uint64) (string) { +func FakeSvcUuid(i uint64) string { return fmt.Sprintf("zzzzz-bi6l4-%015x", i) } -func FakeServiceRoots(n uint64) (map[string]string) { +func FakeServiceRoots(n uint64) map[string]string { sr := map[string]string{} - for i := uint64(0); i < n; i ++ { + for i := uint64(0); i < n; i++ { sr[FakeSvcUuid(i)] = FakeSvcRoot(i) } return sr -- 2.30.2