Skip to content

Commit

Permalink
Fix all non-breaking golint violations
Browse files Browse the repository at this point in the history
  • Loading branch information
dghubble committed Apr 27, 2015
1 parent 15a9d72 commit 7bcba7e
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 37 deletions.
7 changes: 4 additions & 3 deletions .travis.yml
Expand Up @@ -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
- go test -v .
- go vet ./...
46 changes: 23 additions & 23 deletions sling.go
Expand Up @@ -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
Expand All @@ -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
}

Expand Down Expand Up @@ -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
}
Expand All @@ -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{}
Expand Down
22 changes: 11 additions & 11 deletions sling_test.go
Expand Up @@ -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"},
Expand All @@ -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)
}
}
}
Expand Down Expand Up @@ -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},
Expand Down Expand Up @@ -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)
Expand All @@ -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"},
Expand All @@ -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)
}
}
}
Expand Down

0 comments on commit 7bcba7e

Please sign in to comment.