From 7bcba7e58dd7dc454de299ff7d86beae67921ece Mon Sep 17 00:00:00 2001 From: Dalton Hubble Date: Sun, 26 Apr 2015 23:04:19 -0700 Subject: [PATCH] Fix all non-breaking golint violations --- .travis.yml | 7 ++++--- sling.go | 46 +++++++++++++++++++++++----------------------- sling_test.go | 22 +++++++++++----------- 3 files changed, 38 insertions(+), 37 deletions(-) diff --git a/.travis.yml b/.travis.yml index df2b71f..924e56f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,9 +4,10 @@ go: - 1.3 - 1.4 - tip +before_install: + - go get golang.org/x/tools/cmd/vet install: - - go get -v golang.org/x/tools/cmd/vet - go get -v . script: - - go test -v - - go vet \ No newline at end of file + - go test -v . + - go vet ./... \ No newline at end of file diff --git a/sling.go b/sling.go index 5a9b863..9d5b267 100644 --- a/sling.go +++ b/sling.go @@ -94,40 +94,40 @@ func (s *Sling) Client(httpClient *http.Client) *Sling { // Method -// Head sets the Sling method to HEAD and sets the given pathUrl. -func (s *Sling) Head(pathUrl string) *Sling { +// Head sets the Sling method to HEAD and sets the given pathURL. +func (s *Sling) Head(pathURL string) *Sling { s.Method = HEAD - return s.Path(pathUrl) + return s.Path(pathURL) } -// Get sets the Sling method to GET and sets the given pathUrl. -func (s *Sling) Get(pathUrl string) *Sling { +// Get sets the Sling method to GET and sets the given pathURL. +func (s *Sling) Get(pathURL string) *Sling { s.Method = GET - return s.Path(pathUrl) + return s.Path(pathURL) } -// Post sets the Sling method to POST and sets the given pathUrl. -func (s *Sling) Post(pathUrl string) *Sling { +// Post sets the Sling method to POST and sets the given pathURL. +func (s *Sling) Post(pathURL string) *Sling { s.Method = POST - return s.Path(pathUrl) + return s.Path(pathURL) } -// Put sets the Sling method to PUT and sets the given pathUrl. -func (s *Sling) Put(pathUrl string) *Sling { +// Put sets the Sling method to PUT and sets the given pathURL. +func (s *Sling) Put(pathURL string) *Sling { s.Method = PUT - return s.Path(pathUrl) + return s.Path(pathURL) } -// Patch sets the Sling method to PATCH and sets the given pathUrl. -func (s *Sling) Patch(pathUrl string) *Sling { +// Patch sets the Sling method to PATCH and sets the given pathURL. +func (s *Sling) Patch(pathURL string) *Sling { s.Method = PATCH - return s.Path(pathUrl) + return s.Path(pathURL) } -// Delete sets the Sling method to DELETE and sets the given pathUrl. -func (s *Sling) Delete(pathUrl string) *Sling { +// Delete sets the Sling method to DELETE and sets the given pathURL. +func (s *Sling) Delete(pathURL string) *Sling { s.Method = DELETE - return s.Path(pathUrl) + return s.Path(pathURL) } // Header @@ -150,8 +150,8 @@ func (s *Sling) Set(key, value string) *Sling { // Base sets the RawUrl. If you intend to extend the url with Path, // baseUrl should be specified with a trailing slash. -func (s *Sling) Base(rawurl string) *Sling { - s.RawUrl = rawurl +func (s *Sling) Base(rawURL string) *Sling { + s.RawUrl = rawURL return s } @@ -260,7 +260,7 @@ func addQueryStructs(reqURL *url.URL, queryStructs []interface{}) error { // of new Requests. func (s *Sling) getRequestBody() (body io.Reader, err error) { if s.jsonBody != nil && s.Header.Get(contentType) == jsonContentType { - body, err = encodeJsonBody(s.jsonBody) + body, err = encodeJSONBody(s.jsonBody) if err != nil { return nil, err } @@ -273,9 +273,9 @@ func (s *Sling) getRequestBody() (body io.Reader, err error) { return body, nil } -// encodeJsonBody JSON encodes the value pointed to by jsonBody into an +// encodeJSONBody JSON encodes the value pointed to by jsonBody into an // io.Reader, typically for use as a Request Body. -func encodeJsonBody(jsonBody interface{}) (io.Reader, error) { +func encodeJSONBody(jsonBody interface{}) (io.Reader, error) { var buf = new(bytes.Buffer) if jsonBody != nil { buf = &bytes.Buffer{} diff --git a/sling_test.go b/sling_test.go index 7be1d61..f3859bd 100644 --- a/sling_test.go +++ b/sling_test.go @@ -136,9 +136,9 @@ func TestBaseSetter(t *testing.T) { func TestPathSetter(t *testing.T) { cases := []struct { - rawUrl string + rawURL string path string - expectedRawUrl string + expectedRawURL string }{ {"http://a.io/", "foo", "http://a.io/foo"}, {"http://a.io/", "/foo", "http://a.io/foo"}, @@ -159,9 +159,9 @@ func TestPathSetter(t *testing.T) { {"", "", ""}, } for _, c := range cases { - sling := New().Base(c.rawUrl).Path(c.path) - if sling.RawUrl != c.expectedRawUrl { - t.Errorf("expected %s, got %s", c.expectedRawUrl, sling.RawUrl) + sling := New().Base(c.rawURL).Path(c.path) + if sling.RawUrl != c.expectedRawURL { + t.Errorf("expected %s, got %s", c.expectedRawURL, sling.RawUrl) } } } @@ -323,7 +323,7 @@ func TestRequest_urlAndMethod(t *testing.T) { cases := []struct { sling *Sling expectedMethod string - expectedUrl string + expectedURL string expectedErr error }{ {New().Base("http://a.io"), "", "http://a.io", nil}, @@ -351,8 +351,8 @@ func TestRequest_urlAndMethod(t *testing.T) { if err != c.expectedErr { t.Errorf("expected error %v, got %v for %+v", c.expectedErr, err, c.sling) } - if req.URL.String() != c.expectedUrl { - t.Errorf("expected url %s, got %s for %+v", c.expectedUrl, req.URL.String(), c.sling) + if req.URL.String() != c.expectedURL { + t.Errorf("expected url %s, got %s for %+v", c.expectedURL, req.URL.String(), c.sling) } if req.Method != c.expectedMethod { t.Errorf("expected method %s, got %s for %+v", c.expectedMethod, req.Method, c.sling) @@ -363,7 +363,7 @@ func TestRequest_urlAndMethod(t *testing.T) { func TestRequest_queryStructs(t *testing.T) { cases := []struct { sling *Sling - expectedUrl string + expectedURL string }{ {New().Base("http://a.io").QueryStruct(paramsA), "http://a.io?limit=30"}, {New().Base("http://a.io").QueryStruct(paramsA).QueryStruct(paramsB), "http://a.io?count=25&kind_name=recent&limit=30"}, @@ -373,8 +373,8 @@ func TestRequest_queryStructs(t *testing.T) { } for _, c := range cases { req, _ := c.sling.Request() - if req.URL.String() != c.expectedUrl { - t.Errorf("expected url %s, got %s for %+v", c.expectedUrl, req.URL.String(), c.sling) + if req.URL.String() != c.expectedURL { + t.Errorf("expected url %s, got %s for %+v", c.expectedURL, req.URL.String(), c.sling) } } }