diff --git a/github/github.go b/github/github.go index 1bcc4b5..f9e5b63 100644 --- a/github/github.go +++ b/github/github.go @@ -105,18 +105,18 @@ func NewClient(httpClient *http.Client) *Client { return c } -// NewRequest creates an API request. A relative URL can be provided in urls, +// NewRequest creates an API request. A relative URL can be provided in urlStr, // in which case it is resolved relative to the BaseURL of the Client. // Relative URLs should always be specified without a preceding slash. If // specified, the value pointed to by body is JSON encoded and included as the // request body. -func (c *Client) NewRequest(method, urls string, body interface{}) (*http.Request, error) { - rel, err := url.Parse(urls) +func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error) { + rel, err := url.Parse(urlStr) if err != nil { return nil, err } - url_ := c.BaseURL.ResolveReference(rel) + u := c.BaseURL.ResolveReference(rel) buf := new(bytes.Buffer) if body != nil { @@ -126,7 +126,7 @@ func (c *Client) NewRequest(method, urls string, body interface{}) (*http.Reques } } - req, err := http.NewRequest(method, url_.String(), buf) + req, err := http.NewRequest(method, u.String(), buf) if err != nil { return nil, err } diff --git a/github/orgs.go b/github/orgs.go index de4ea91..361fede 100644 --- a/github/orgs.go +++ b/github/orgs.go @@ -48,20 +48,20 @@ type Team struct { // // GitHub API docs: http://developer.github.com/v3/orgs/#list-user-organizations func (s *OrganizationsService) List(user string, opt *ListOptions) ([]Organization, error) { - var url_ string + var u string if user != "" { - url_ = fmt.Sprintf("users/%v/orgs", user) + u = fmt.Sprintf("users/%v/orgs", user) } else { - url_ = "user/orgs" + u = "user/orgs" } if opt != nil { params := url.Values{ "page": []string{strconv.Itoa(opt.Page)}, } - url_ += "?" + params.Encode() + u += "?" + params.Encode() } - req, err := s.client.NewRequest("GET", url_, nil) + req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, err } @@ -75,8 +75,8 @@ func (s *OrganizationsService) List(user string, opt *ListOptions) ([]Organizati // // GitHub API docs: http://developer.github.com/v3/orgs/#get-an-organization func (s *OrganizationsService) Get(org string) (*Organization, error) { - url_ := fmt.Sprintf("orgs/%v", org) - req, err := s.client.NewRequest("GET", url_, nil) + u := fmt.Sprintf("orgs/%v", org) + req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, err } @@ -90,8 +90,8 @@ func (s *OrganizationsService) Get(org string) (*Organization, error) { // // GitHub API docs: http://developer.github.com/v3/orgs/#edit-an-organization func (s *OrganizationsService) Edit(name string, org *Organization) (*Organization, error) { - url_ := fmt.Sprintf("orgs/%v", name) - req, err := s.client.NewRequest("PATCH", url_, org) + u := fmt.Sprintf("orgs/%v", name) + req, err := s.client.NewRequest("PATCH", u, org) if err != nil { return nil, err } @@ -107,8 +107,8 @@ func (s *OrganizationsService) Edit(name string, org *Organization) (*Organizati // // GitHub API docs: http://developer.github.com/v3/orgs/members/#members-list func (s *OrganizationsService) ListMembers(org string) ([]User, error) { - url_ := fmt.Sprintf("orgs/%v/members", org) - req, err := s.client.NewRequest("GET", url_, nil) + u := fmt.Sprintf("orgs/%v/members", org) + req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, err } @@ -122,8 +122,8 @@ func (s *OrganizationsService) ListMembers(org string) ([]User, error) { // // GitHub API docs: http://developer.github.com/v3/orgs/members/#public-members-list func (s *OrganizationsService) ListPublicMembers(org string) ([]User, error) { - url_ := fmt.Sprintf("orgs/%v/public_members", org) - req, err := s.client.NewRequest("GET", url_, nil) + u := fmt.Sprintf("orgs/%v/public_members", org) + req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, err } @@ -137,8 +137,8 @@ func (s *OrganizationsService) ListPublicMembers(org string) ([]User, error) { // // GitHub API docs: http://developer.github.com/v3/orgs/members/#check-membership func (s *OrganizationsService) CheckMembership(org, user string) (bool, error) { - url_ := fmt.Sprintf("orgs/%v/members/%v", org, user) - req, err := s.client.NewRequest("GET", url_, nil) + u := fmt.Sprintf("orgs/%v/members/%v", org, user) + req, err := s.client.NewRequest("GET", u, nil) if err != nil { return false, err } @@ -151,8 +151,8 @@ func (s *OrganizationsService) CheckMembership(org, user string) (bool, error) { // // GitHub API docs: http://developer.github.com/v3/orgs/members/#check-public-membership func (s *OrganizationsService) CheckPublicMembership(org, user string) (bool, error) { - url_ := fmt.Sprintf("orgs/%v/public_members/%v", org, user) - req, err := s.client.NewRequest("GET", url_, nil) + u := fmt.Sprintf("orgs/%v/public_members/%v", org, user) + req, err := s.client.NewRequest("GET", u, nil) if err != nil { return false, err } @@ -165,8 +165,8 @@ func (s *OrganizationsService) CheckPublicMembership(org, user string) (bool, er // // GitHub API docs: http://developer.github.com/v3/orgs/members/#remove-a-member func (s *OrganizationsService) RemoveMember(org, user string) error { - url_ := fmt.Sprintf("orgs/%v/members/%v", org, user) - req, err := s.client.NewRequest("DELETE", url_, nil) + u := fmt.Sprintf("orgs/%v/members/%v", org, user) + req, err := s.client.NewRequest("DELETE", u, nil) if err != nil { return err } @@ -179,8 +179,8 @@ func (s *OrganizationsService) RemoveMember(org, user string) error { // // GitHub API docs: http://developer.github.com/v3/orgs/members/#publicize-a-users-membership func (s *OrganizationsService) PublicizeMembership(org, user string) error { - url_ := fmt.Sprintf("orgs/%v/public_members/%v", org, user) - req, err := s.client.NewRequest("PUT", url_, nil) + u := fmt.Sprintf("orgs/%v/public_members/%v", org, user) + req, err := s.client.NewRequest("PUT", u, nil) if err != nil { return err } @@ -193,8 +193,8 @@ func (s *OrganizationsService) PublicizeMembership(org, user string) error { // // GitHub API docs: http://developer.github.com/v3/orgs/members/#conceal-a-users-membership func (s *OrganizationsService) ConcealMembership(org, user string) error { - url_ := fmt.Sprintf("orgs/%v/public_members/%v", org, user) - req, err := s.client.NewRequest("DELETE", url_, nil) + u := fmt.Sprintf("orgs/%v/public_members/%v", org, user) + req, err := s.client.NewRequest("DELETE", u, nil) if err != nil { return err } @@ -207,8 +207,8 @@ func (s *OrganizationsService) ConcealMembership(org, user string) error { // // GitHub API docs: http://developer.github.com/v3/orgs/teams/#list-teams func (s *OrganizationsService) ListTeams(org string) ([]Team, error) { - url_ := fmt.Sprintf("orgs/%v/teams", org) - req, err := s.client.NewRequest("GET", url_, nil) + u := fmt.Sprintf("orgs/%v/teams", org) + req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, err } @@ -222,8 +222,8 @@ func (s *OrganizationsService) ListTeams(org string) ([]Team, error) { // // GitHub API docs: http://developer.github.com/v3/orgs/teams/#get-team func (s *OrganizationsService) GetTeam(team int) (*Team, error) { - url_ := fmt.Sprintf("teams/%v", team) - req, err := s.client.NewRequest("GET", url_, nil) + u := fmt.Sprintf("teams/%v", team) + req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, err } @@ -237,8 +237,8 @@ func (s *OrganizationsService) GetTeam(team int) (*Team, error) { // // GitHub API docs: http://developer.github.com/v3/orgs/teams/#create-team func (s *OrganizationsService) CreateTeam(org string, team *Team) (*Team, error) { - url_ := fmt.Sprintf("orgs/%v/teams", org) - req, err := s.client.NewRequest("POST", url_, team) + u := fmt.Sprintf("orgs/%v/teams", org) + req, err := s.client.NewRequest("POST", u, team) if err != nil { return nil, err } @@ -252,8 +252,8 @@ func (s *OrganizationsService) CreateTeam(org string, team *Team) (*Team, error) // // GitHub API docs: http://developer.github.com/v3/orgs/teams/#edit-team func (s *OrganizationsService) EditTeam(id int, team *Team) (*Team, error) { - url_ := fmt.Sprintf("teams/%v", id) - req, err := s.client.NewRequest("PATCH", url_, team) + u := fmt.Sprintf("teams/%v", id) + req, err := s.client.NewRequest("PATCH", u, team) if err != nil { return nil, err } @@ -267,8 +267,8 @@ func (s *OrganizationsService) EditTeam(id int, team *Team) (*Team, error) { // // GitHub API docs: http://developer.github.com/v3/orgs/teams/#delete-team func (s *OrganizationsService) DeleteTeam(team int) error { - url_ := fmt.Sprintf("teams/%v", team) - req, err := s.client.NewRequest("DELETE", url_, nil) + u := fmt.Sprintf("teams/%v", team) + req, err := s.client.NewRequest("DELETE", u, nil) if err != nil { return err } @@ -282,8 +282,8 @@ func (s *OrganizationsService) DeleteTeam(team int) error { // // GitHub API docs: http://developer.github.com/v3/orgs/teams/#list-team-members func (s *OrganizationsService) ListTeamMembers(team int) ([]User, error) { - url_ := fmt.Sprintf("teams/%v/members", team) - req, err := s.client.NewRequest("GET", url_, nil) + u := fmt.Sprintf("teams/%v/members", team) + req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, err } @@ -297,8 +297,8 @@ func (s *OrganizationsService) ListTeamMembers(team int) ([]User, error) { // // GitHub API docs: http://developer.github.com/v3/orgs/teams/#get-team-member func (s *OrganizationsService) CheckTeamMembership(team int, user string) (bool, error) { - url_ := fmt.Sprintf("teams/%v/members/%v", team, user) - req, err := s.client.NewRequest("GET", url_, nil) + u := fmt.Sprintf("teams/%v/members/%v", team, user) + req, err := s.client.NewRequest("GET", u, nil) if err != nil { return false, err } @@ -311,8 +311,8 @@ func (s *OrganizationsService) CheckTeamMembership(team int, user string) (bool, // // GitHub API docs: http://developer.github.com/v3/orgs/teams/#add-team-member func (s *OrganizationsService) AddTeamMember(team int, user string) error { - url_ := fmt.Sprintf("teams/%v/members/%v", team, user) - req, err := s.client.NewRequest("PUT", url_, nil) + u := fmt.Sprintf("teams/%v/members/%v", team, user) + req, err := s.client.NewRequest("PUT", u, nil) if err != nil { return err } @@ -325,8 +325,8 @@ func (s *OrganizationsService) AddTeamMember(team int, user string) error { // // GitHub API docs: http://developer.github.com/v3/orgs/teams/#remove-team-member func (s *OrganizationsService) RemoveTeamMember(team int, user string) error { - url_ := fmt.Sprintf("teams/%v/members/%v", team, user) - req, err := s.client.NewRequest("DELETE", url_, nil) + u := fmt.Sprintf("teams/%v/members/%v", team, user) + req, err := s.client.NewRequest("DELETE", u, nil) if err != nil { return err } @@ -339,8 +339,8 @@ func (s *OrganizationsService) RemoveTeamMember(team int, user string) error { // // GitHub API docs: http://developer.github.com/v3/orgs/teams/#list-team-repos func (s *OrganizationsService) ListTeamRepos(team int) ([]Repository, error) { - url_ := fmt.Sprintf("teams/%v/repos", team) - req, err := s.client.NewRequest("GET", url_, nil) + u := fmt.Sprintf("teams/%v/repos", team) + req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, err } @@ -354,8 +354,8 @@ func (s *OrganizationsService) ListTeamRepos(team int) ([]Repository, error) { // // GitHub API docs: http://developer.github.com/v3/orgs/teams/#get-team-repo func (s *OrganizationsService) CheckTeamRepo(team int, owner string, repo string) (bool, error) { - url_ := fmt.Sprintf("teams/%v/repos/%v/%v", team, owner, repo) - req, err := s.client.NewRequest("GET", url_, nil) + u := fmt.Sprintf("teams/%v/repos/%v/%v", team, owner, repo) + req, err := s.client.NewRequest("GET", u, nil) if err != nil { return false, err } @@ -370,8 +370,8 @@ func (s *OrganizationsService) CheckTeamRepo(team int, owner string, repo string // // GitHub API docs: http://developer.github.com/v3/orgs/teams/#add-team-repo func (s *OrganizationsService) AddTeamRepo(team int, owner string, repo string) error { - url_ := fmt.Sprintf("teams/%v/repos/%v/%v", team, owner, repo) - req, err := s.client.NewRequest("PUT", url_, nil) + u := fmt.Sprintf("teams/%v/repos/%v/%v", team, owner, repo) + req, err := s.client.NewRequest("PUT", u, nil) if err != nil { return err } @@ -386,8 +386,8 @@ func (s *OrganizationsService) AddTeamRepo(team int, owner string, repo string) // // GitHub API docs: http://developer.github.com/v3/orgs/teams/#remove-team-repo func (s *OrganizationsService) RemoveTeamRepo(team int, owner string, repo string) error { - url_ := fmt.Sprintf("teams/%v/repos/%v/%v", team, owner, repo) - req, err := s.client.NewRequest("DELETE", url_, nil) + u := fmt.Sprintf("teams/%v/repos/%v/%v", team, owner, repo) + req, err := s.client.NewRequest("DELETE", u, nil) if err != nil { return err } diff --git a/github/repos.go b/github/repos.go index 06b89b0..54c223e 100644 --- a/github/repos.go +++ b/github/repos.go @@ -56,11 +56,11 @@ type RepositoryListOptions struct { // // GitHub API docs: http://developer.github.com/v3/repos/#list-user-repositories func (s *RepositoriesService) List(user string, opt *RepositoryListOptions) ([]Repository, error) { - var url_ string + var u string if user != "" { - url_ = fmt.Sprintf("users/%v/repos", user) + u = fmt.Sprintf("users/%v/repos", user) } else { - url_ = "user/repos" + u = "user/repos" } if opt != nil { params := url.Values{ @@ -69,10 +69,10 @@ func (s *RepositoriesService) List(user string, opt *RepositoryListOptions) ([]R "direction": []string{opt.Direction}, "page": []string{strconv.Itoa(opt.Page)}, } - url_ += "?" + params.Encode() + u += "?" + params.Encode() } - req, err := s.client.NewRequest("GET", url_, nil) + req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, err } @@ -97,16 +97,16 @@ type RepositoryListByOrgOptions struct { // // GitHub API docs: http://developer.github.com/v3/repos/#list-organization-repositories func (s *RepositoriesService) ListByOrg(org string, opt *RepositoryListByOrgOptions) ([]Repository, error) { - url_ := fmt.Sprintf("orgs/%v/repos", org) + u := fmt.Sprintf("orgs/%v/repos", org) if opt != nil { params := url.Values{ "type": []string{opt.Type}, "page": []string{strconv.Itoa(opt.Page)}, } - url_ += "?" + params.Encode() + u += "?" + params.Encode() } - req, err := s.client.NewRequest("GET", url_, nil) + req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, err } @@ -127,15 +127,15 @@ type RepositoryListAllOptions struct { // // GitHub API docs: http://developer.github.com/v3/repos/#list-all-repositories func (s *RepositoriesService) ListAll(opt *RepositoryListAllOptions) ([]Repository, error) { - url_ := "repositories" + u := "repositories" if opt != nil { params := url.Values{ "since": []string{strconv.Itoa(opt.Since)}, } - url_ += "?" + params.Encode() + u += "?" + params.Encode() } - req, err := s.client.NewRequest("GET", url_, nil) + req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, err } @@ -151,14 +151,14 @@ func (s *RepositoriesService) ListAll(opt *RepositoryListAllOptions) ([]Reposito // // GitHub API docs: http://developer.github.com/v3/repos/#create func (s *RepositoriesService) Create(org string, repo *Repository) (*Repository, error) { - var url_ string + var u string if org != "" { - url_ = fmt.Sprintf("orgs/%v/repos", org) + u = fmt.Sprintf("orgs/%v/repos", org) } else { - url_ = "user/repos" + u = "user/repos" } - req, err := s.client.NewRequest("POST", url_, repo) + req, err := s.client.NewRequest("POST", u, repo) if err != nil { return nil, err } @@ -172,8 +172,8 @@ func (s *RepositoriesService) Create(org string, repo *Repository) (*Repository, // // GitHub API docs: http://developer.github.com/v3/repos/#get func (s *RepositoriesService) Get(owner, repo string) (*Repository, error) { - url_ := fmt.Sprintf("repos/%v/%v", owner, repo) - req, err := s.client.NewRequest("GET", url_, nil) + u := fmt.Sprintf("repos/%v/%v", owner, repo) + req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, err } @@ -194,15 +194,15 @@ type RepositoryListForksOptions struct { // // GitHub API docs: http://developer.github.com/v3/repos/forks/#list-forks func (s *RepositoriesService) ListForks(owner, repo string, opt *RepositoryListForksOptions) ([]Repository, error) { - url_ := fmt.Sprintf("repos/%v/%v/forks", owner, repo) + u := fmt.Sprintf("repos/%v/%v/forks", owner, repo) if opt != nil { params := url.Values{ "sort": []string{opt.Sort}, } - url_ += "?" + params.Encode() + u += "?" + params.Encode() } - req, err := s.client.NewRequest("GET", url_, nil) + req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, err } @@ -223,15 +223,15 @@ type RepositoryCreateForkOptions struct { // // GitHub API docs: http://developer.github.com/v3/repos/forks/#list-forks func (s *RepositoriesService) CreateFork(owner, repo string, opt *RepositoryCreateForkOptions) (*Repository, error) { - url_ := fmt.Sprintf("repos/%v/%v/forks", owner, repo) + u := fmt.Sprintf("repos/%v/%v/forks", owner, repo) if opt != nil { params := url.Values{ "organization": []string{opt.Organization}, } - url_ += "?" + params.Encode() + u += "?" + params.Encode() } - req, err := s.client.NewRequest("POST", url_, nil) + req, err := s.client.NewRequest("POST", u, nil) if err != nil { return nil, err } @@ -266,8 +266,8 @@ type RepoStatus struct { // // GitHub API docs: http://developer.github.com/v3/repos/statuses/#list-statuses-for-a-specific-ref func (s *RepositoriesService) ListStatuses(owner, repo, ref string) ([]RepoStatus, error) { - url_ := fmt.Sprintf("repos/%v/%v/statuses/%v", owner, repo, ref) - req, err := s.client.NewRequest("GET", url_, nil) + u := fmt.Sprintf("repos/%v/%v/statuses/%v", owner, repo, ref) + req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, err } @@ -282,8 +282,8 @@ func (s *RepositoriesService) ListStatuses(owner, repo, ref string) ([]RepoStatu // // GitHub API docs: http://developer.github.com/v3/repos/statuses/#create-a-status func (s *RepositoriesService) CreateStatus(owner, repo, ref string, status *RepoStatus) (*RepoStatus, error) { - url_ := fmt.Sprintf("repos/%v/%v/statuses/%v", owner, repo, ref) - req, err := s.client.NewRequest("POST", url_, status) + u := fmt.Sprintf("repos/%v/%v/statuses/%v", owner, repo, ref) + req, err := s.client.NewRequest("POST", u, status) if err != nil { return nil, err } diff --git a/github/users.go b/github/users.go index a2050f1..6cc5f9e 100644 --- a/github/users.go +++ b/github/users.go @@ -45,35 +45,35 @@ type User struct { // // GitHub API docs: http://developer.github.com/v3/users/#get-a-single-user func (s *UsersService) Get(user string) (*User, error) { - var url_ string + var u string if user != "" { - url_ = fmt.Sprintf("users/%v", user) + u = fmt.Sprintf("users/%v", user) } else { - url_ = "user" + u = "user" } - req, err := s.client.NewRequest("GET", url_, nil) + req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, err } - u := new(User) - _, err = s.client.Do(req, u) - return u, err + uResp := new(User) + _, err = s.client.Do(req, uResp) + return uResp, err } // Edit the authenticated user. // // GitHub API docs: http://developer.github.com/v3/users/#update-the-authenticated-user func (s *UsersService) Edit(user *User) (*User, error) { - url_ := "user" - req, err := s.client.NewRequest("PATCH", url_, user) + u := "user" + req, err := s.client.NewRequest("PATCH", u, user) if err != nil { return nil, err } - u := new(User) - _, err = s.client.Do(req, u) - return u, err + uResp := new(User) + _, err = s.client.Do(req, uResp) + return uResp, err } // UserListOptions specifies optional parameters to the UsersService.List @@ -87,15 +87,15 @@ type UserListOptions struct { // // GitHub API docs: http://developer.github.com/v3/users/#get-all-users func (s *UsersService) ListAll(opt *UserListOptions) ([]User, error) { - url_ := "users" + u := "users" if opt != nil { params := url.Values{ "since": []string{strconv.Itoa(opt.Since)}, } - url_ += "?" + params.Encode() + u += "?" + params.Encode() } - req, err := s.client.NewRequest("GET", url_, nil) + req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, err }