{"action":"created","comment":{"url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/pulls/comments/186009323","pull_request_review_id":117500300,"id":186009323,"diff_hunk":"@@ -0,0 +1,88 @@\n+package calendar\n+\n+import (\n+\t\"log\"\n+\t\"time\"\n+\n+\t\"github.com/romukey/GoogleCalendar2SlackInGolang/conf\"\n+\t\"github.com/romukey/GoogleCalendar2SlackInGolang/util/time\"\n+\tgcalendar \"google.golang.org/api/calendar/v3\"\n+)\n+\n+type (\n+\t// Service service interface\n+\tService interface {\n+\t\tFetchTomorrowGuidanceEvents() ([]*gcalendar.Event, error)\n+\t}\n+\n+\t// ServiceImpl service implementation struct\n+\tServiceImpl struct {\n+\t\tGService *gcalendar.Service\n+\t}\n+)\n+\n+// NewService new service constructor\n+func NewService() Service {\n+\treturn &ServiceImpl{GService: getGService()}\n+}\n+\n+func getGService() *gcalendar.Service {\n+\tgService, err := gcalendar.New(NewClient())\n+\tif err != nil {\n+\t\tlog.Fatalf(\"Unable to create google service implementation: %v\", err)\n+\t}\n+\treturn gService\n+}\n+\n+// FetchTomorrowGuidanceEvents fetch tomorrow guidance events from calendar.\n+func (s *ServiceImpl) FetchTomorrowGuidanceEvents() ([]*gcalendar.Event, error) {\n+\ttomorrow := timeset.GetBeginningOfDate(time.Now().AddDate(0, 0, 1))\n+\tdayAfterTomorrow := timeset.GetBeginningOfDate(time.Now().AddDate(0, 0, 2))\n+\n+\tcalendarID, err := s.getGuidanceCalendarID()\n+\tif err != nil {\n+\t\tlog.Fatalf(\"Unable to retrieve guidance calendar id: %v\", err)\n+\t}\n+\n+\tevents, err := s.GService.Events.\n+\t\tList(calendarID).\n+\t\tShowDeleted(false).SingleEvents(true).\n+\t\tTimeMin(tomorrow).TimeMax(dayAfterTomorrow).\n+\t\tOrderBy(\"startTime\").\n+\t\tDo()\n+\n+\tif err != nil {\n+\t\tlog.Fatalf(\"Unable to retrieve tomorrow's guidance events: %v\", err)\n+\t}\n+\titems := events.Items\n+\tif len(items) == 0 {\n+\t\tlog.Fatalf(\"there is no guidance events tomorrow\")\n+\t}\n+\n+\treturn items, err\n+}\n+\n+// getGuidanceCalendarID get guidance calenar id\n+func (s *ServiceImpl) getGuidanceCalendarID() (string, error) {","path":"calendar/service.go","position":66,"original_position":66,"commit_id":"398dcbe5fab953935d072552152c16930728bfb1","original_commit_id":"398dcbe5fab953935d072552152c16930728bfb1","user":{"login":"mnrtks","id":1425542,"avatar_url":"https://avatars2.githubusercontent.com/u/1425542?v=4","gravatar_id":"","url":"https://api.github.com/users/mnrtks","html_url":"https://github.com/mnrtks","followers_url":"https://api.github.com/users/mnrtks/followers","following_url":"https://api.github.com/users/mnrtks/following{/other_user}","gists_url":"https://api.github.com/users/mnrtks/gists{/gist_id}","starred_url":"https://api.github.com/users/mnrtks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mnrtks/subscriptions","organizations_url":"https://api.github.com/users/mnrtks/orgs","repos_url":"https://api.github.com/users/mnrtks/repos","events_url":"https://api.github.com/users/mnrtks/events{/privacy}","received_events_url":"https://api.github.com/users/mnrtks/received_events","type":"User","site_admin":false},"body":"戻り値が `(string, error)` となってますがエラー値を返すコードパスがないですね。\r\nちゃんとerrorを返すようにするかシグネチャを変更するかしたほうが良さそうです。\r\nこの場合は `log.Fatal` を撲滅して全部エラーを返すようにするべきですが。","created_at":"2018-05-04T07:47:22Z","updated_at":"2018-05-04T07:53:46Z","html_url":"https://github.com/romukey/GoogleCalendar2SlackInGolang/pull/1#discussion_r186009323","pull_request_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/pulls/1","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/pulls/comments/186009323"},"html":{"href":"https://github.com/romukey/GoogleCalendar2SlackInGolang/pull/1#discussion_r186009323"},"pull_request":{"href":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/pulls/1","id":185345737,"html_url":"https://github.com/romukey/GoogleCalendar2SlackInGolang/pull/1","diff_url":"https://github.com/romukey/GoogleCalendar2SlackInGolang/pull/1.diff","patch_url":"https://github.com/romukey/GoogleCalendar2SlackInGolang/pull/1.patch","issue_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/issues/1","number":1,"state":"open","locked":false,"title":"Google Canlendarからイベントを取得する。","user":{"login":"romukey","id":22656143,"avatar_url":"https://avatars3.githubusercontent.com/u/22656143?v=4","gravatar_id":"","url":"https://api.github.com/users/romukey","html_url":"https://github.com/romukey","followers_url":"https://api.github.com/users/romukey/followers","following_url":"https://api.github.com/users/romukey/following{/other_user}","gists_url":"https://api.github.com/users/romukey/gists{/gist_id}","starred_url":"https://api.github.com/users/romukey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/romukey/subscriptions","organizations_url":"https://api.github.com/users/romukey/orgs","repos_url":"https://api.github.com/users/romukey/repos","events_url":"https://api.github.com/users/romukey/events{/privacy}","received_events_url":"https://api.github.com/users/romukey/received_events","type":"User","site_admin":false},"body":"## WHY\r\n - google calendarからイベントを取得する。\r\n- 仕様に沿って、次の日に行われる予定で、アカウントの「受講生(n回目)面談」というカレンダーで登録されているイベントを取得できるようにした。\r\n","created_at":"2018-05-02T06:27:02Z","updated_at":"2018-05-04T07:53:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"19de1b2ff1d63d323fbd1818c01bac753ce165e6","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/pulls/1/commits","review_comments_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/pulls/1/comments","review_comment_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/pulls/comments{/number}","comments_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/issues/1/comments","statuses_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/statuses/398dcbe5fab953935d072552152c16930728bfb1","head":{"label":"romukey:feature/fetch_events_from_google_calendar","ref":"feature/fetch_events_from_google_calendar","sha":"398dcbe5fab953935d072552152c16930728bfb1","user":{"login":"romukey","id":22656143,"avatar_url":"https://avatars3.githubusercontent.com/u/22656143?v=4","gravatar_id":"","url":"https://api.github.com/users/romukey","html_url":"https://github.com/romukey","followers_url":"https://api.github.com/users/romukey/followers","following_url":"https://api.github.com/users/romukey/following{/other_user}","gists_url":"https://api.github.com/users/romukey/gists{/gist_id}","starred_url":"https://api.github.com/users/romukey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/romukey/subscriptions","organizations_url":"https://api.github.com/users/romukey/orgs","repos_url":"https://api.github.com/users/romukey/repos","events_url":"https://api.github.com/users/romukey/events{/privacy}","received_events_url":"https://api.github.com/users/romukey/received_events","type":"User","site_admin":false},"repo":{"id":127376803,"name":"GoogleCalendar2SlackInGolang","full_name":"romukey/GoogleCalendar2SlackInGolang","owner":{"login":"romukey","id":22656143,"avatar_url":"https://avatars3.githubusercontent.com/u/22656143?v=4","gravatar_id":"","url":"https://api.github.com/users/romukey","html_url":"https://github.com/romukey","followers_url":"https://api.github.com/users/romukey/followers","following_url":"https://api.github.com/users/romukey/following{/other_user}","gists_url":"https://api.github.com/users/romukey/gists{/gist_id}","starred_url":"https://api.github.com/users/romukey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/romukey/subscriptions","organizations_url":"https://api.github.com/users/romukey/orgs","repos_url":"https://api.github.com/users/romukey/repos","events_url":"https://api.github.com/users/romukey/events{/privacy}","received_events_url":"https://api.github.com/users/romukey/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/romukey/GoogleCalendar2SlackInGolang","description":"event reminder on google calendar to slack in golang ","fork":false,"url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang","forks_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/forks","keys_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/keys{/key_id}","collaborators_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/teams","hooks_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/hooks","issue_events_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/issues/events{/number}","events_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/events","assignees_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/assignees{/user}","branches_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/branches{/branch}","tags_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/tags","blobs_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/git/refs{/sha}","trees_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/git/trees{/sha}","statuses_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/statuses/{sha}","languages_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/languages","stargazers_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/stargazers","contributors_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/contributors","subscribers_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/subscribers","subscription_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/subscription","commits_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/commits{/sha}","git_commits_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/git/commits{/sha}","comments_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/comments{/number}","issue_comment_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/issues/comments{/number}","contents_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/contents/{+path}","compare_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/compare/{base}...{head}","merges_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/merges","archive_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/downloads","issues_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/issues{/number}","pulls_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/pulls{/number}","milestones_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/milestones{/number}","notifications_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/labels{/name}","releases_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/releases{/id}","deployments_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/deployments","created_at":"2018-03-30T03:27:14Z","updated_at":"2018-05-02T04:56:53Z","pushed_at":"2018-05-04T05:47:39Z","git_url":"git://github.com/romukey/GoogleCalendar2SlackInGolang.git","ssh_url":"git@github.com:romukey/GoogleCalendar2SlackInGolang.git","clone_url":"https://github.com/romukey/GoogleCalendar2SlackInGolang.git","svn_url":"https://github.com/romukey/GoogleCalendar2SlackInGolang","homepage":null,"size":11,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"romukey:master","ref":"master","sha":"21435365702110a51ac6597d7ca2bf7fa4e30288","user":{"login":"romukey","id":22656143,"avatar_url":"https://avatars3.githubusercontent.com/u/22656143?v=4","gravatar_id":"","url":"https://api.github.com/users/romukey","html_url":"https://github.com/romukey","followers_url":"https://api.github.com/users/romukey/followers","following_url":"https://api.github.com/users/romukey/following{/other_user}","gists_url":"https://api.github.com/users/romukey/gists{/gist_id}","starred_url":"https://api.github.com/users/romukey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/romukey/subscriptions","organizations_url":"https://api.github.com/users/romukey/orgs","repos_url":"https://api.github.com/users/romukey/repos","events_url":"https://api.github.com/users/romukey/events{/privacy}","received_events_url":"https://api.github.com/users/romukey/received_events","type":"User","site_admin":false},"repo":{"id":127376803,"name":"GoogleCalendar2SlackInGolang","full_name":"romukey/GoogleCalendar2SlackInGolang","owner":{"login":"romukey","id":22656143,"avatar_url":"https://avatars3.githubusercontent.com/u/22656143?v=4","gravatar_id":"","url":"https://api.github.com/users/romukey","html_url":"https://github.com/romukey","followers_url":"https://api.github.com/users/romukey/followers","following_url":"https://api.github.com/users/romukey/following{/other_user}","gists_url":"https://api.github.com/users/romukey/gists{/gist_id}","starred_url":"https://api.github.com/users/romukey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/romukey/subscriptions","organizations_url":"https://api.github.com/users/romukey/orgs","repos_url":"https://api.github.com/users/romukey/repos","events_url":"https://api.github.com/users/romukey/events{/privacy}","received_events_url":"https://api.github.com/users/romukey/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/romukey/GoogleCalendar2SlackInGolang","description":"event reminder on google calendar to slack in golang ","fork":false,"url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang","forks_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/forks","keys_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/keys{/key_id}","collaborators_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/teams","hooks_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/hooks","issue_events_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/issues/events{/number}","events_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/events","assignees_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/assignees{/user}","branches_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/branches{/branch}","tags_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/tags","blobs_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/git/refs{/sha}","trees_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/git/trees{/sha}","statuses_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/statuses/{sha}","languages_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/languages","stargazers_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/stargazers","contributors_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/contributors","subscribers_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/subscribers","subscription_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/subscription","commits_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/commits{/sha}","git_commits_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/git/commits{/sha}","comments_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/comments{/number}","issue_comment_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/issues/comments{/number}","contents_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/contents/{+path}","compare_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/compare/{base}...{head}","merges_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/merges","archive_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/downloads","issues_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/issues{/number}","pulls_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/pulls{/number}","milestones_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/milestones{/number}","notifications_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/labels{/name}","releases_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/releases{/id}","deployments_url":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/deployments","created_at":"2018-03-30T03:27:14Z","updated_at":"2018-05-02T04:56:53Z","pushed_at":"2018-05-04T05:47:39Z","git_url":"git://github.com/romukey/GoogleCalendar2SlackInGolang.git","ssh_url":"git@github.com:romukey/GoogleCalendar2SlackInGolang.git","clone_url":"https://github.com/romukey/GoogleCalendar2SlackInGolang.git","svn_url":"https://github.com/romukey/GoogleCalendar2SlackInGolang","homepage":null,"size":11,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/pulls/1"},"html":{"href":"https://github.com/romukey/GoogleCalendar2SlackInGolang/pull/1"},"issue":{"href":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/issues/1"},"comments":{"href":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/romukey/GoogleCalendar2SlackInGolang/statuses/398dcbe5fab953935d072552152c16930728bfb1"}},"author_association":"OWNER"}}
{"actor":{"display_login":"mnrtks"}}