From 303846dd0424d0fe46aea798d1969ff99b0aa1ac Mon Sep 17 00:00:00 2001 From: Will Norris Date: Wed, 21 Aug 2013 15:12:11 -0700 Subject: [PATCH] redeclare String() as value method throughout --- github/activity_events.go | 6 +++--- github/gists.go | 4 ++-- github/gists_comments.go | 2 +- github/git_commits.go | 4 ++-- github/git_trees.go | 4 ++-- github/issues.go | 2 +- github/issues_comments.go | 2 +- github/orgs.go | 2 +- github/orgs_teams.go | 2 +- github/pulls.go | 2 +- github/pulls_comments.go | 2 +- github/repos.go | 2 +- github/repos_comments.go | 2 +- github/repos_hooks.go | 8 ++++---- github/repos_statuses.go | 2 +- github/search.go | 2 +- github/strings.go | 2 +- github/strings_test.go | 4 ++++ github/timestamp.go | 2 +- github/users.go | 2 +- 20 files changed, 31 insertions(+), 27 deletions(-) diff --git a/github/activity_events.go b/github/activity_events.go index b57b648..7438a9a 100644 --- a/github/activity_events.go +++ b/github/activity_events.go @@ -25,7 +25,7 @@ type Event struct { ID *string `json:"id,omitempty"` } -func (e *Event) String() string { +func (e Event) String() string { return Stringify(e) } @@ -53,7 +53,7 @@ type PushEvent struct { Commits []PushEventCommit `json:"commits,omitempty"` } -func (p *PushEvent) String() string { +func (p PushEvent) String() string { return Stringify(p) } @@ -66,7 +66,7 @@ type PushEventCommit struct { Distinct *bool `json:"distinct"` } -func (p *PushEventCommit) String() string { +func (p PushEventCommit) String() string { return Stringify(p) } diff --git a/github/gists.go b/github/gists.go index 7b5112a..65e7710 100644 --- a/github/gists.go +++ b/github/gists.go @@ -33,7 +33,7 @@ type Gist struct { CreatedAt *time.Time `json:"created_at,omitempty"` } -func (g *Gist) String() string { +func (g Gist) String() string { return Stringify(g) } @@ -48,7 +48,7 @@ type GistFile struct { Content *string `json:"content,omitempty"` } -func (g *GistFile) String() string { +func (g GistFile) String() string { return Stringify(g) } diff --git a/github/gists_comments.go b/github/gists_comments.go index 9d792e5..dabd68a 100644 --- a/github/gists_comments.go +++ b/github/gists_comments.go @@ -19,7 +19,7 @@ type GistComment struct { CreatedAt *time.Time `json:"created_at,omitempty"` } -func (g *GistComment) String() string { +func (g GistComment) String() string { return Stringify(g) } diff --git a/github/git_commits.go b/github/git_commits.go index 3c9b7a4..82a178d 100644 --- a/github/git_commits.go +++ b/github/git_commits.go @@ -20,7 +20,7 @@ type Commit struct { Parents []Commit `json:"parents,omitempty"` } -func (c *Commit) String() string { +func (c Commit) String() string { return Stringify(c) } @@ -32,7 +32,7 @@ type CommitAuthor struct { Email *string `json:"email,omitempty"` } -func (c *CommitAuthor) String() string { +func (c CommitAuthor) String() string { return Stringify(c) } diff --git a/github/git_trees.go b/github/git_trees.go index 2b21cdb..92af126 100644 --- a/github/git_trees.go +++ b/github/git_trees.go @@ -13,7 +13,7 @@ type Tree struct { Entries []TreeEntry `json:"tree,omitempty"` } -func (t *Tree) String() string { +func (t Tree) String() string { return Stringify(t) } @@ -28,7 +28,7 @@ type TreeEntry struct { Size *int `json:"size,omitempty"` } -func (t *TreeEntry) String() string { +func (t TreeEntry) String() string { return Stringify(t) } diff --git a/github/issues.go b/github/issues.go index f4d6f6d..6fabf3e 100644 --- a/github/issues.go +++ b/github/issues.go @@ -38,7 +38,7 @@ type Issue struct { // TODO(willnorris): milestone } -func (i *Issue) String() string { +func (i Issue) String() string { return Stringify(i) } diff --git a/github/issues_comments.go b/github/issues_comments.go index acb5f0e..222c141 100644 --- a/github/issues_comments.go +++ b/github/issues_comments.go @@ -20,7 +20,7 @@ type IssueComment struct { UpdatedAt *time.Time `json:"updated_at,omitempty"` } -func (i *IssueComment) String() string { +func (i IssueComment) String() string { return Stringify(i) } diff --git a/github/orgs.go b/github/orgs.go index 0bc90d4..664dbdb 100644 --- a/github/orgs.go +++ b/github/orgs.go @@ -30,7 +30,7 @@ type Organization struct { CreatedAt *time.Time `json:"created_at,omitempty"` } -func (o *Organization) String() string { +func (o Organization) String() string { return Stringify(o) } diff --git a/github/orgs_teams.go b/github/orgs_teams.go index 8c36a65..dda4cb2 100644 --- a/github/orgs_teams.go +++ b/github/orgs_teams.go @@ -19,7 +19,7 @@ type Team struct { ReposCount *int `json:"repos_count,omitempty"` } -func (t *Team) String() string { +func (t Team) String() string { return Stringify(t) } diff --git a/github/pulls.go b/github/pulls.go index cfec684..fac3d9c 100644 --- a/github/pulls.go +++ b/github/pulls.go @@ -42,7 +42,7 @@ type PullRequest struct { // TODO(willnorris): add head and base once we have a Commit struct defined somewhere } -func (p *PullRequest) String() string { +func (p PullRequest) String() string { return Stringify(p) } diff --git a/github/pulls_comments.go b/github/pulls_comments.go index a062a46..7505d4b 100644 --- a/github/pulls_comments.go +++ b/github/pulls_comments.go @@ -23,7 +23,7 @@ type PullRequestComment struct { UpdatedAt *time.Time `json:"updated_at,omitempty"` } -func (p *PullRequestComment) String() string { +func (p PullRequestComment) String() string { return Stringify(p) } diff --git a/github/repos.go b/github/repos.go index 642eb02..6096e60 100644 --- a/github/repos.go +++ b/github/repos.go @@ -37,7 +37,7 @@ type Repository struct { HasWiki *bool `json:"has_wiki"` } -func (r *Repository) String() string { +func (r Repository) String() string { return Stringify(r) } diff --git a/github/repos_comments.go b/github/repos_comments.go index 0f71562..0348905 100644 --- a/github/repos_comments.go +++ b/github/repos_comments.go @@ -27,7 +27,7 @@ type RepositoryComment struct { Position *int `json:"position,omitempty"` } -func (r *RepositoryComment) String() string { +func (r RepositoryComment) String() string { return Stringify(r) } diff --git a/github/repos_hooks.go b/github/repos_hooks.go index 0acb011..44d20e1 100644 --- a/github/repos_hooks.go +++ b/github/repos_hooks.go @@ -33,7 +33,7 @@ type WebHookPayload struct { Repo *Repository `json:"repository,omitempty"` } -func (w *WebHookPayload) String() string { +func (w WebHookPayload) String() string { return Stringify(w) } @@ -51,7 +51,7 @@ type WebHookCommit struct { Timestamp *time.Time `json:"timestamp,omitempty"` } -func (w *WebHookCommit) String() string { +func (w WebHookCommit) String() string { return Stringify(w) } @@ -63,7 +63,7 @@ type WebHookAuthor struct { Username *string `json:"username,omitempty"` } -func (w *WebHookAuthor) String() string { +func (w WebHookAuthor) String() string { return Stringify(w) } @@ -78,7 +78,7 @@ type Hook struct { ID *int `json:"id,omitempty"` } -func (h *Hook) String() string { +func (h Hook) String() string { return Stringify(h) } diff --git a/github/repos_statuses.go b/github/repos_statuses.go index 305b6bd..7d7c2a1 100644 --- a/github/repos_statuses.go +++ b/github/repos_statuses.go @@ -30,7 +30,7 @@ type RepoStatus struct { UpdatedAt *time.Time `json:"updated_at,omitempty"` } -func (r *RepoStatus) String() string { +func (r RepoStatus) String() string { return Stringify(r) } diff --git a/github/search.go b/github/search.go index 2370960..3bdbc6f 100644 --- a/github/search.go +++ b/github/search.go @@ -102,7 +102,7 @@ type CodeResult struct { Repository *Repository `json:"repository,omitempty"` } -func (c *CodeResult) String() string { +func (c CodeResult) String() string { return Stringify(c) } diff --git a/github/strings.go b/github/strings.go index c877251..3857723 100644 --- a/github/strings.go +++ b/github/strings.go @@ -57,7 +57,7 @@ func stringifyValue(w io.Writer, val reflect.Value) { // special handling of Timestamp values if v.Type() == timestampType { - fmt.Fprint(w, v.Interface()) + fmt.Fprintf(w, "{%s}", v.Interface()) return } diff --git a/github/strings_test.go b/github/strings_test.go index d6f5764..ffeee28 100644 --- a/github/strings_test.go +++ b/github/strings_test.go @@ -56,6 +56,10 @@ func TestStringify(t *testing.T) { Timestamp{time.Date(2006, 01, 02, 15, 04, 05, 0, time.UTC)}, `github.Timestamp{2006-01-02 15:04:05 +0000 UTC}`, }, + { + &Timestamp{time.Date(2006, 01, 02, 15, 04, 05, 0, time.UTC)}, + `github.Timestamp{2006-01-02 15:04:05 +0000 UTC}`, + }, { User{ID: Int(123), Name: String("n")}, `github.User{ID:123, Name:"n"}`, diff --git a/github/timestamp.go b/github/timestamp.go index 47b7e04..a1c1554 100644 --- a/github/timestamp.go +++ b/github/timestamp.go @@ -18,7 +18,7 @@ type Timestamp struct { time.Time } -func (t *Timestamp) String() string { +func (t Timestamp) String() string { return t.Time.String() } diff --git a/github/users.go b/github/users.go index c165ea8..c092bbc 100644 --- a/github/users.go +++ b/github/users.go @@ -39,7 +39,7 @@ type User struct { CreatedAt *time.Time `json:"created_at,omitempty"` } -func (u *User) String() string { +func (u User) String() string { return Stringify(u) }