{"action":"created","comment":{"url":"https://api.github.com/repos/kklipsch/kay/pulls/comments/25009516","id":25009516,"diff_hunk":"@@ -0,0 +1,103 @@\n+package main\n+\n+import (\n+\t\"fmt\"\n+\t\"time\"\n+)\n+\n+type Year int\n+type File string\n+type Tag string\n+type Note string\n+\n+type index struct {\n+\trecords map[File]*record\n+}\n+\n+func EmptyIndex() *index {\n+\treturn &index{(map[File]*record{})}\n+}\n+\n+func (i *index) ContainsFile(file File) bool {\n+\t_, contains := i.records[file]\n+\treturn contains\n+}\n+\n+func (i *index) Get(file File) *record {\n+\trecord, _ := i.records[file]\n+\treturn record\n+}\n+\n+func (i *index) CreateRecord(year Year, file File, note Note, tags ...Tag) (*record, error) {\n+\tr := record{file, year, note, time.Now(), time.Now(), tags}\n+\treturn i.addRecord(&r, file, false)\n+}\n+\n+func (i *index) addRecord(r *record, newFile File, replace bool) (*record, error) {\n+\tif i.ContainsFile(newFile) {\n+\t\treturn nil, fmt.Errorf(\"Attempting to add record for file that exists in index: %s\", newFile)\n+\t}\n+\n+\tif replace {\n+\t\tdelerr := i.DeleteRecord(r)\n+\t\tif delerr != nil {\n+\t\t\treturn nil, delerr\n+\t\t}\n+\t}\n+\n+\tr.file = newFile\n+\ti.records[newFile] = r\n+\n+\treturn r, nil\n+}\n+\n+func (i *index) SetRecord(r *record, newFile File) (*record, error) {\n+\treturn i.addRecord(r, newFile, false)\n+}\n+\n+func (i *index) MoveRecord(r *record, newFile File) (*record, error) {\n+\treturn i.addRecord(r, newFile, true)\n+}\n+\n+func (i *index) DeleteRecord(r *record) error {\n+\tif !i.ContainsFile(r.File()) {\n+\t\treturn fmt.Errorf(\"File %v is not in index.\", r.File())\n+\t}\n+\n+\tdelete(i.records, r.File())\n+\treturn nil\n+}\n+\n+func (i *index) Records() []*record {\n+\trecords := []*record{}\n+\tfor _, record := range i.records {\n+\t\trecords = append(records, record)\n+\t}\n+\treturn records\n+}\n+\n+type record struct {\n+\t//changing the file should be done through the index\n+\tfile File\n+\n+\tYear        Year\n+\tNote        Note\n+\tDateAdded   time.Time\n+\tLastWritten time.Time\n+\tTags        []Tag\n+}\n+\n+func (r record) File() File {\n+\treturn r.file\n+}\n+\n+func (r record) HasTag(tag Tag) bool {\n+\t//golang doesnt have a contains function for arrays?","path":"index.go","position":95,"original_position":95,"commit_id":"67f5bf3f60d646bdc029d54302eb4539ec9ba77d","original_commit_id":"67f5bf3f60d646bdc029d54302eb4539ec9ba77d","user":{"login":"bhand-mm","id":5913552,"avatar_url":"https://avatars.githubusercontent.com/u/5913552?v=3","gravatar_id":"","url":"https://api.github.com/users/bhand-mm","html_url":"https://github.com/bhand-mm","followers_url":"https://api.github.com/users/bhand-mm/followers","following_url":"https://api.github.com/users/bhand-mm/following{/other_user}","gists_url":"https://api.github.com/users/bhand-mm/gists{/gist_id}","starred_url":"https://api.github.com/users/bhand-mm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bhand-mm/subscriptions","organizations_url":"https://api.github.com/users/bhand-mm/orgs","repos_url":"https://api.github.com/users/bhand-mm/repos","events_url":"https://api.github.com/users/bhand-mm/events{/privacy}","received_events_url":"https://api.github.com/users/bhand-mm/received_events","type":"User","site_admin":false},"body":"You are *lucky* it even has append/insert.  Also this is a slice not an array.  A distinction of which we must be ever vigilant!","created_at":"2015-02-19T18:02:54Z","updated_at":"2015-02-19T18:02:54Z","html_url":"https://github.com/kklipsch/kay/pull/1#discussion_r25009516","pull_request_url":"https://api.github.com/repos/kklipsch/kay/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/kklipsch/kay/pulls/comments/25009516"},"html":{"href":"https://github.com/kklipsch/kay/pull/1#discussion_r25009516"},"pull_request":{"href":"https://api.github.com/repos/kklipsch/kay/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/kklipsch/kay/pulls/1","id":29585188,"html_url":"https://github.com/kklipsch/kay/pull/1","diff_url":"https://github.com/kklipsch/kay/pull/1.diff","patch_url":"https://github.com/kklipsch/kay/pull/1.patch","issue_url":"https://api.github.com/repos/kklipsch/kay/issues/1","number":1,"state":"open","locked":false,"title":"First commit to the golang implementation.","user":{"login":"kklipsch","id":673953,"avatar_url":"https://avatars.githubusercontent.com/u/673953?v=3","gravatar_id":"","url":"https://api.github.com/users/kklipsch","html_url":"https://github.com/kklipsch","followers_url":"https://api.github.com/users/kklipsch/followers","following_url":"https://api.github.com/users/kklipsch/following{/other_user}","gists_url":"https://api.github.com/users/kklipsch/gists{/gist_id}","starred_url":"https://api.github.com/users/kklipsch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kklipsch/subscriptions","organizations_url":"https://api.github.com/users/kklipsch/orgs","repos_url":"https://api.github.com/users/kklipsch/repos","events_url":"https://api.github.com/users/kklipsch/events{/privacy}","received_events_url":"https://api.github.com/users/kklipsch/received_events","type":"User","site_admin":false},"body":"This gets the code to the point where a simple add/stat query works.  Test coverage is not great but should be easy to add.","created_at":"2015-02-19T03:39:44Z","updated_at":"2015-02-19T18:02:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b8af5c4284f29c14d5ed1f0881063d2626933e5e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/kklipsch/kay/pulls/1/commits","review_comments_url":"https://api.github.com/repos/kklipsch/kay/pulls/1/comments","review_comment_url":"https://api.github.com/repos/kklipsch/kay/pulls/comments/{number}","comments_url":"https://api.github.com/repos/kklipsch/kay/issues/1/comments","statuses_url":"https://api.github.com/repos/kklipsch/kay/statuses/67f5bf3f60d646bdc029d54302eb4539ec9ba77d","head":{"label":"go/first_pass","ref":"go/first_pass","sha":"67f5bf3f60d646bdc029d54302eb4539ec9ba77d","user":{"login":"kklipsch","id":673953,"avatar_url":"https://avatars.githubusercontent.com/u/673953?v=3","gravatar_id":"","url":"https://api.github.com/users/kklipsch","html_url":"https://github.com/kklipsch","followers_url":"https://api.github.com/users/kklipsch/followers","following_url":"https://api.github.com/users/kklipsch/following{/other_user}","gists_url":"https://api.github.com/users/kklipsch/gists{/gist_id}","starred_url":"https://api.github.com/users/kklipsch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kklipsch/subscriptions","organizations_url":"https://api.github.com/users/kklipsch/orgs","repos_url":"https://api.github.com/users/kklipsch/repos","events_url":"https://api.github.com/users/kklipsch/events{/privacy}","received_events_url":"https://api.github.com/users/kklipsch/received_events","type":"User","site_admin":false},"repo":{"id":30843658,"name":"kay","full_name":"kklipsch/kay","owner":{"login":"kklipsch","id":673953,"avatar_url":"https://avatars.githubusercontent.com/u/673953?v=3","gravatar_id":"","url":"https://api.github.com/users/kklipsch","html_url":"https://github.com/kklipsch","followers_url":"https://api.github.com/users/kklipsch/followers","following_url":"https://api.github.com/users/kklipsch/following{/other_user}","gists_url":"https://api.github.com/users/kklipsch/gists{/gist_id}","starred_url":"https://api.github.com/users/kklipsch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kklipsch/subscriptions","organizations_url":"https://api.github.com/users/kklipsch/orgs","repos_url":"https://api.github.com/users/kklipsch/repos","events_url":"https://api.github.com/users/kklipsch/events{/privacy}","received_events_url":"https://api.github.com/users/kklipsch/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kklipsch/kay","description":"A command line tool to keep track of autobiography chapters organized by year.","fork":false,"url":"https://api.github.com/repos/kklipsch/kay","forks_url":"https://api.github.com/repos/kklipsch/kay/forks","keys_url":"https://api.github.com/repos/kklipsch/kay/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kklipsch/kay/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kklipsch/kay/teams","hooks_url":"https://api.github.com/repos/kklipsch/kay/hooks","issue_events_url":"https://api.github.com/repos/kklipsch/kay/issues/events{/number}","events_url":"https://api.github.com/repos/kklipsch/kay/events","assignees_url":"https://api.github.com/repos/kklipsch/kay/assignees{/user}","branches_url":"https://api.github.com/repos/kklipsch/kay/branches{/branch}","tags_url":"https://api.github.com/repos/kklipsch/kay/tags","blobs_url":"https://api.github.com/repos/kklipsch/kay/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kklipsch/kay/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kklipsch/kay/git/refs{/sha}","trees_url":"https://api.github.com/repos/kklipsch/kay/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kklipsch/kay/statuses/{sha}","languages_url":"https://api.github.com/repos/kklipsch/kay/languages","stargazers_url":"https://api.github.com/repos/kklipsch/kay/stargazers","contributors_url":"https://api.github.com/repos/kklipsch/kay/contributors","subscribers_url":"https://api.github.com/repos/kklipsch/kay/subscribers","subscription_url":"https://api.github.com/repos/kklipsch/kay/subscription","commits_url":"https://api.github.com/repos/kklipsch/kay/commits{/sha}","git_commits_url":"https://api.github.com/repos/kklipsch/kay/git/commits{/sha}","comments_url":"https://api.github.com/repos/kklipsch/kay/comments{/number}","issue_comment_url":"https://api.github.com/repos/kklipsch/kay/issues/comments/{number}","contents_url":"https://api.github.com/repos/kklipsch/kay/contents/{+path}","compare_url":"https://api.github.com/repos/kklipsch/kay/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kklipsch/kay/merges","archive_url":"https://api.github.com/repos/kklipsch/kay/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kklipsch/kay/downloads","issues_url":"https://api.github.com/repos/kklipsch/kay/issues{/number}","pulls_url":"https://api.github.com/repos/kklipsch/kay/pulls{/number}","milestones_url":"https://api.github.com/repos/kklipsch/kay/milestones{/number}","notifications_url":"https://api.github.com/repos/kklipsch/kay/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kklipsch/kay/labels{/name}","releases_url":"https://api.github.com/repos/kklipsch/kay/releases{/id}","created_at":"2015-02-15T21:53:08Z","updated_at":"2015-02-15T21:54:04Z","pushed_at":"2015-02-19T15:49:13Z","git_url":"git://github.com/kklipsch/kay.git","ssh_url":"git@github.com:kklipsch/kay.git","clone_url":"https://github.com/kklipsch/kay.git","svn_url":"https://github.com/kklipsch/kay","homepage":"","size":0,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"golang"}},"base":{"label":"golang","ref":"golang","sha":"f6306854107bfcc12ba0d8f8003bef5093a26d8b","user":{"login":"kklipsch","id":673953,"avatar_url":"https://avatars.githubusercontent.com/u/673953?v=3","gravatar_id":"","url":"https://api.github.com/users/kklipsch","html_url":"https://github.com/kklipsch","followers_url":"https://api.github.com/users/kklipsch/followers","following_url":"https://api.github.com/users/kklipsch/following{/other_user}","gists_url":"https://api.github.com/users/kklipsch/gists{/gist_id}","starred_url":"https://api.github.com/users/kklipsch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kklipsch/subscriptions","organizations_url":"https://api.github.com/users/kklipsch/orgs","repos_url":"https://api.github.com/users/kklipsch/repos","events_url":"https://api.github.com/users/kklipsch/events{/privacy}","received_events_url":"https://api.github.com/users/kklipsch/received_events","type":"User","site_admin":false},"repo":{"id":30843658,"name":"kay","full_name":"kklipsch/kay","owner":{"login":"kklipsch","id":673953,"avatar_url":"https://avatars.githubusercontent.com/u/673953?v=3","gravatar_id":"","url":"https://api.github.com/users/kklipsch","html_url":"https://github.com/kklipsch","followers_url":"https://api.github.com/users/kklipsch/followers","following_url":"https://api.github.com/users/kklipsch/following{/other_user}","gists_url":"https://api.github.com/users/kklipsch/gists{/gist_id}","starred_url":"https://api.github.com/users/kklipsch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kklipsch/subscriptions","organizations_url":"https://api.github.com/users/kklipsch/orgs","repos_url":"https://api.github.com/users/kklipsch/repos","events_url":"https://api.github.com/users/kklipsch/events{/privacy}","received_events_url":"https://api.github.com/users/kklipsch/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kklipsch/kay","description":"A command line tool to keep track of autobiography chapters organized by year.","fork":false,"url":"https://api.github.com/repos/kklipsch/kay","forks_url":"https://api.github.com/repos/kklipsch/kay/forks","keys_url":"https://api.github.com/repos/kklipsch/kay/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kklipsch/kay/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kklipsch/kay/teams","hooks_url":"https://api.github.com/repos/kklipsch/kay/hooks","issue_events_url":"https://api.github.com/repos/kklipsch/kay/issues/events{/number}","events_url":"https://api.github.com/repos/kklipsch/kay/events","assignees_url":"https://api.github.com/repos/kklipsch/kay/assignees{/user}","branches_url":"https://api.github.com/repos/kklipsch/kay/branches{/branch}","tags_url":"https://api.github.com/repos/kklipsch/kay/tags","blobs_url":"https://api.github.com/repos/kklipsch/kay/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kklipsch/kay/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kklipsch/kay/git/refs{/sha}","trees_url":"https://api.github.com/repos/kklipsch/kay/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kklipsch/kay/statuses/{sha}","languages_url":"https://api.github.com/repos/kklipsch/kay/languages","stargazers_url":"https://api.github.com/repos/kklipsch/kay/stargazers","contributors_url":"https://api.github.com/repos/kklipsch/kay/contributors","subscribers_url":"https://api.github.com/repos/kklipsch/kay/subscribers","subscription_url":"https://api.github.com/repos/kklipsch/kay/subscription","commits_url":"https://api.github.com/repos/kklipsch/kay/commits{/sha}","git_commits_url":"https://api.github.com/repos/kklipsch/kay/git/commits{/sha}","comments_url":"https://api.github.com/repos/kklipsch/kay/comments{/number}","issue_comment_url":"https://api.github.com/repos/kklipsch/kay/issues/comments/{number}","contents_url":"https://api.github.com/repos/kklipsch/kay/contents/{+path}","compare_url":"https://api.github.com/repos/kklipsch/kay/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kklipsch/kay/merges","archive_url":"https://api.github.com/repos/kklipsch/kay/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kklipsch/kay/downloads","issues_url":"https://api.github.com/repos/kklipsch/kay/issues{/number}","pulls_url":"https://api.github.com/repos/kklipsch/kay/pulls{/number}","milestones_url":"https://api.github.com/repos/kklipsch/kay/milestones{/number}","notifications_url":"https://api.github.com/repos/kklipsch/kay/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kklipsch/kay/labels{/name}","releases_url":"https://api.github.com/repos/kklipsch/kay/releases{/id}","created_at":"2015-02-15T21:53:08Z","updated_at":"2015-02-15T21:54:04Z","pushed_at":"2015-02-19T15:49:13Z","git_url":"git://github.com/kklipsch/kay.git","ssh_url":"git@github.com:kklipsch/kay.git","clone_url":"https://github.com/kklipsch/kay.git","svn_url":"https://github.com/kklipsch/kay","homepage":"","size":0,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"golang"}},"_links":{"self":{"href":"https://api.github.com/repos/kklipsch/kay/pulls/1"},"html":{"href":"https://github.com/kklipsch/kay/pull/1"},"issue":{"href":"https://api.github.com/repos/kklipsch/kay/issues/1"},"comments":{"href":"https://api.github.com/repos/kklipsch/kay/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/kklipsch/kay/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/kklipsch/kay/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/kklipsch/kay/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/kklipsch/kay/statuses/67f5bf3f60d646bdc029d54302eb4539ec9ba77d"}}}}