{"action":"created","comment":{"url":"https://api.github.com/repos/himanshuo/gameoflife/pulls/comments/46068512","id":46068512,"diff_hunk":"@@ -0,0 +1,323 @@\n+package main\n+\n+import (\n+\t\"database/sql\"\n+\t\"encoding/json\"\n+\t\"github.com/gorilla/mux\"\n+\t\"github.com/himanshuo/gameoflife/models\"\n+\t_ \"github.com/mattn/go-sqlite3\"\n+\t\"html/template\"\n+\t\"log\"\n+\t\"net/http\"\n+\t\"strconv\"\n+)\n+\n+//_ is in order to import a package solely for its side-effects at initialization.\n+//In this case, go-sqlite3's side effects are allowing sqlite3 to be usable as a\n+//database for  sql.Open\n+\n+//the database resource\n+var db *sql.DB\n+var Router *mux.Router\n+\n+//run at start of program.\n+func init() {\n+\n+\tstartDB()\n+\tRouter = mux.NewRouter()\n+\n+}\n+\n+func startDB() error {\n+\tvar err error\n+\t//sqlite 3 database is stored in /data/data.db file\n+\tdb, err = sql.Open(\"sqlite3\", \"./data/data.db\")\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\n+\t//make sure we can actually query the database.\n+\tif err := db.Ping(); err != nil {\n+\t\treturn err\n+\t}\n+\n+\t//ASSUMPTION: table exists in database\n+\n+\t//statement creates Task table which only has a PK id and name textfields\n+\tsqlStmt := \"create table Task (id integer not null primary key autoincrement, name text);\"\n+\t//run statement to create table. return object of Result type is not needed.\n+\t_, err = db.Exec(sqlStmt)\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\tlog.Printf(\"Database Started\")\n+\treturn nil\n+}\n+\n+//Views\n+// Home page view. For now, simply lists all the tasks one by one.\n+func Home(w http.ResponseWriter, r *http.Request) {\n+\tlog.Printf(\"Home Screen Opened\")\n+\t//get all tasks\n+\trows, err := db.Query(\"select id, name from Task\")\n+\tif err != nil {\n+\t\tlog.Fatal(err)\n+\t}\n+\tdefer rows.Close()\n+\n+\t//list of tasks\n+\ttasks := []models.Task{}\n+\n+\t//iterate through response\n+\tfor rows.Next() {\n+\t\tvar id int\n+\t\tvar name string\n+\t\t//fill id and name variables with db output\n+\t\trows.Scan(&id, &name)\n+\t\t//create new controller model for task\n+\t\tcurTask := models.Task{Id: id, Name: name}\n+\t\t//add model to tasks list\n+\t\ttasks = append(tasks, curTask)","path":"main.go","position":80,"original_position":80,"commit_id":"8431b6ae86d26aae19ab95ef57630b8a0f77e276","original_commit_id":"8431b6ae86d26aae19ab95ef57630b8a0f77e276","user":{"login":"himanshuo","id":5808841,"avatar_url":"https://avatars.githubusercontent.com/u/5808841?v=3","gravatar_id":"","url":"https://api.github.com/users/himanshuo","html_url":"https://github.com/himanshuo","followers_url":"https://api.github.com/users/himanshuo/followers","following_url":"https://api.github.com/users/himanshuo/following{/other_user}","gists_url":"https://api.github.com/users/himanshuo/gists{/gist_id}","starred_url":"https://api.github.com/users/himanshuo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/himanshuo/subscriptions","organizations_url":"https://api.github.com/users/himanshuo/orgs","repos_url":"https://api.github.com/users/himanshuo/repos","events_url":"https://api.github.com/users/himanshuo/events{/privacy}","received_events_url":"https://api.github.com/users/himanshuo/received_events","type":"User","site_admin":false},"body":"Make sure append is correct. Just read docs to make sure this entire for loop is running efficiently. ","created_at":"2015-11-27T20:02:22Z","updated_at":"2015-11-27T20:02:22Z","html_url":"https://github.com/himanshuo/gameoflife/pull/17#discussion_r46068512","pull_request_url":"https://api.github.com/repos/himanshuo/gameoflife/pulls/17","_links":{"self":{"href":"https://api.github.com/repos/himanshuo/gameoflife/pulls/comments/46068512"},"html":{"href":"https://github.com/himanshuo/gameoflife/pull/17#discussion_r46068512"},"pull_request":{"href":"https://api.github.com/repos/himanshuo/gameoflife/pulls/17"}}},"pull_request":{"url":"https://api.github.com/repos/himanshuo/gameoflife/pulls/17","id":51441608,"html_url":"https://github.com/himanshuo/gameoflife/pull/17","diff_url":"https://github.com/himanshuo/gameoflife/pull/17.diff","patch_url":"https://github.com/himanshuo/gameoflife/pull/17.patch","issue_url":"https://api.github.com/repos/himanshuo/gameoflife/issues/17","number":17,"state":"open","locked":false,"title":"[CR] Start the website in Golang using a custom web framework","user":{"login":"himanshuo","id":5808841,"avatar_url":"https://avatars.githubusercontent.com/u/5808841?v=3","gravatar_id":"","url":"https://api.github.com/users/himanshuo","html_url":"https://github.com/himanshuo","followers_url":"https://api.github.com/users/himanshuo/followers","following_url":"https://api.github.com/users/himanshuo/following{/other_user}","gists_url":"https://api.github.com/users/himanshuo/gists{/gist_id}","starred_url":"https://api.github.com/users/himanshuo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/himanshuo/subscriptions","organizations_url":"https://api.github.com/users/himanshuo/orgs","repos_url":"https://api.github.com/users/himanshuo/repos","events_url":"https://api.github.com/users/himanshuo/events{/privacy}","received_events_url":"https://api.github.com/users/himanshuo/received_events","type":"User","site_admin":false},"body":"*Problem*\r\nThis feature creates the initials for having a full fledged application working. This feature specifically just creates a basic task model and provides an API to access the model.\r\n\r\n*Issue*\r\nhttps://github.com/himanshuo/gameoflife/issues/1\r\n\r\n*Status*\r\n- [x] create basic models\r\n- [x] routing  \r\n- [x] create very basic template\r\n- [x] have model populate template [HOLD]\r\n- [x] have some way to store the data\r\n- [x] doctype explanation of all methods\r\n- [x] handle todos\r\n- [x] optimal runtime\r\n- [x] erronous input should be handled [HOLD]\r\n- [x] tests\r\n- [x] linters := gofmt\r\n- [ ] CR (mark as code review. Then go through diff and mark it up.)","created_at":"2015-11-21T13:47:22Z","updated_at":"2015-11-27T20:02:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"da4d9c20054460192ce3cf36c42d4ea8f668b356","assignee":{"login":"himanshuo","id":5808841,"avatar_url":"https://avatars.githubusercontent.com/u/5808841?v=3","gravatar_id":"","url":"https://api.github.com/users/himanshuo","html_url":"https://github.com/himanshuo","followers_url":"https://api.github.com/users/himanshuo/followers","following_url":"https://api.github.com/users/himanshuo/following{/other_user}","gists_url":"https://api.github.com/users/himanshuo/gists{/gist_id}","starred_url":"https://api.github.com/users/himanshuo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/himanshuo/subscriptions","organizations_url":"https://api.github.com/users/himanshuo/orgs","repos_url":"https://api.github.com/users/himanshuo/repos","events_url":"https://api.github.com/users/himanshuo/events{/privacy}","received_events_url":"https://api.github.com/users/himanshuo/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/himanshuo/gameoflife/pulls/17/commits","review_comments_url":"https://api.github.com/repos/himanshuo/gameoflife/pulls/17/comments","review_comment_url":"https://api.github.com/repos/himanshuo/gameoflife/pulls/comments{/number}","comments_url":"https://api.github.com/repos/himanshuo/gameoflife/issues/17/comments","statuses_url":"https://api.github.com/repos/himanshuo/gameoflife/statuses/8431b6ae86d26aae19ab95ef57630b8a0f77e276","head":{"label":"himanshuo:feature/init_framework","ref":"feature/init_framework","sha":"8431b6ae86d26aae19ab95ef57630b8a0f77e276","user":{"login":"himanshuo","id":5808841,"avatar_url":"https://avatars.githubusercontent.com/u/5808841?v=3","gravatar_id":"","url":"https://api.github.com/users/himanshuo","html_url":"https://github.com/himanshuo","followers_url":"https://api.github.com/users/himanshuo/followers","following_url":"https://api.github.com/users/himanshuo/following{/other_user}","gists_url":"https://api.github.com/users/himanshuo/gists{/gist_id}","starred_url":"https://api.github.com/users/himanshuo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/himanshuo/subscriptions","organizations_url":"https://api.github.com/users/himanshuo/orgs","repos_url":"https://api.github.com/users/himanshuo/repos","events_url":"https://api.github.com/users/himanshuo/events{/privacy}","received_events_url":"https://api.github.com/users/himanshuo/received_events","type":"User","site_admin":false},"repo":{"id":45922197,"name":"gameoflife","full_name":"himanshuo/gameoflife","owner":{"login":"himanshuo","id":5808841,"avatar_url":"https://avatars.githubusercontent.com/u/5808841?v=3","gravatar_id":"","url":"https://api.github.com/users/himanshuo","html_url":"https://github.com/himanshuo","followers_url":"https://api.github.com/users/himanshuo/followers","following_url":"https://api.github.com/users/himanshuo/following{/other_user}","gists_url":"https://api.github.com/users/himanshuo/gists{/gist_id}","starred_url":"https://api.github.com/users/himanshuo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/himanshuo/subscriptions","organizations_url":"https://api.github.com/users/himanshuo/orgs","repos_url":"https://api.github.com/users/himanshuo/repos","events_url":"https://api.github.com/users/himanshuo/events{/privacy}","received_events_url":"https://api.github.com/users/himanshuo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/himanshuo/gameoflife","description":"The Game of Life","fork":false,"url":"https://api.github.com/repos/himanshuo/gameoflife","forks_url":"https://api.github.com/repos/himanshuo/gameoflife/forks","keys_url":"https://api.github.com/repos/himanshuo/gameoflife/keys{/key_id}","collaborators_url":"https://api.github.com/repos/himanshuo/gameoflife/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/himanshuo/gameoflife/teams","hooks_url":"https://api.github.com/repos/himanshuo/gameoflife/hooks","issue_events_url":"https://api.github.com/repos/himanshuo/gameoflife/issues/events{/number}","events_url":"https://api.github.com/repos/himanshuo/gameoflife/events","assignees_url":"https://api.github.com/repos/himanshuo/gameoflife/assignees{/user}","branches_url":"https://api.github.com/repos/himanshuo/gameoflife/branches{/branch}","tags_url":"https://api.github.com/repos/himanshuo/gameoflife/tags","blobs_url":"https://api.github.com/repos/himanshuo/gameoflife/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/himanshuo/gameoflife/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/himanshuo/gameoflife/git/refs{/sha}","trees_url":"https://api.github.com/repos/himanshuo/gameoflife/git/trees{/sha}","statuses_url":"https://api.github.com/repos/himanshuo/gameoflife/statuses/{sha}","languages_url":"https://api.github.com/repos/himanshuo/gameoflife/languages","stargazers_url":"https://api.github.com/repos/himanshuo/gameoflife/stargazers","contributors_url":"https://api.github.com/repos/himanshuo/gameoflife/contributors","subscribers_url":"https://api.github.com/repos/himanshuo/gameoflife/subscribers","subscription_url":"https://api.github.com/repos/himanshuo/gameoflife/subscription","commits_url":"https://api.github.com/repos/himanshuo/gameoflife/commits{/sha}","git_commits_url":"https://api.github.com/repos/himanshuo/gameoflife/git/commits{/sha}","comments_url":"https://api.github.com/repos/himanshuo/gameoflife/comments{/number}","issue_comment_url":"https://api.github.com/repos/himanshuo/gameoflife/issues/comments{/number}","contents_url":"https://api.github.com/repos/himanshuo/gameoflife/contents/{+path}","compare_url":"https://api.github.com/repos/himanshuo/gameoflife/compare/{base}...{head}","merges_url":"https://api.github.com/repos/himanshuo/gameoflife/merges","archive_url":"https://api.github.com/repos/himanshuo/gameoflife/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/himanshuo/gameoflife/downloads","issues_url":"https://api.github.com/repos/himanshuo/gameoflife/issues{/number}","pulls_url":"https://api.github.com/repos/himanshuo/gameoflife/pulls{/number}","milestones_url":"https://api.github.com/repos/himanshuo/gameoflife/milestones{/number}","notifications_url":"https://api.github.com/repos/himanshuo/gameoflife/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/himanshuo/gameoflife/labels{/name}","releases_url":"https://api.github.com/repos/himanshuo/gameoflife/releases{/id}","created_at":"2015-11-10T15:48:04Z","updated_at":"2015-11-21T13:47:55Z","pushed_at":"2015-11-27T17:07:47Z","git_url":"git://github.com/himanshuo/gameoflife.git","ssh_url":"git@github.com:himanshuo/gameoflife.git","clone_url":"https://github.com/himanshuo/gameoflife.git","svn_url":"https://github.com/himanshuo/gameoflife","homepage":null,"size":1476,"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":27,"forks":0,"open_issues":27,"watchers":0,"default_branch":"develop"}},"base":{"label":"himanshuo:develop","ref":"develop","sha":"70ca83755cb30beed66be1d9ea36e83f0ac12a63","user":{"login":"himanshuo","id":5808841,"avatar_url":"https://avatars.githubusercontent.com/u/5808841?v=3","gravatar_id":"","url":"https://api.github.com/users/himanshuo","html_url":"https://github.com/himanshuo","followers_url":"https://api.github.com/users/himanshuo/followers","following_url":"https://api.github.com/users/himanshuo/following{/other_user}","gists_url":"https://api.github.com/users/himanshuo/gists{/gist_id}","starred_url":"https://api.github.com/users/himanshuo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/himanshuo/subscriptions","organizations_url":"https://api.github.com/users/himanshuo/orgs","repos_url":"https://api.github.com/users/himanshuo/repos","events_url":"https://api.github.com/users/himanshuo/events{/privacy}","received_events_url":"https://api.github.com/users/himanshuo/received_events","type":"User","site_admin":false},"repo":{"id":45922197,"name":"gameoflife","full_name":"himanshuo/gameoflife","owner":{"login":"himanshuo","id":5808841,"avatar_url":"https://avatars.githubusercontent.com/u/5808841?v=3","gravatar_id":"","url":"https://api.github.com/users/himanshuo","html_url":"https://github.com/himanshuo","followers_url":"https://api.github.com/users/himanshuo/followers","following_url":"https://api.github.com/users/himanshuo/following{/other_user}","gists_url":"https://api.github.com/users/himanshuo/gists{/gist_id}","starred_url":"https://api.github.com/users/himanshuo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/himanshuo/subscriptions","organizations_url":"https://api.github.com/users/himanshuo/orgs","repos_url":"https://api.github.com/users/himanshuo/repos","events_url":"https://api.github.com/users/himanshuo/events{/privacy}","received_events_url":"https://api.github.com/users/himanshuo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/himanshuo/gameoflife","description":"The Game of Life","fork":false,"url":"https://api.github.com/repos/himanshuo/gameoflife","forks_url":"https://api.github.com/repos/himanshuo/gameoflife/forks","keys_url":"https://api.github.com/repos/himanshuo/gameoflife/keys{/key_id}","collaborators_url":"https://api.github.com/repos/himanshuo/gameoflife/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/himanshuo/gameoflife/teams","hooks_url":"https://api.github.com/repos/himanshuo/gameoflife/hooks","issue_events_url":"https://api.github.com/repos/himanshuo/gameoflife/issues/events{/number}","events_url":"https://api.github.com/repos/himanshuo/gameoflife/events","assignees_url":"https://api.github.com/repos/himanshuo/gameoflife/assignees{/user}","branches_url":"https://api.github.com/repos/himanshuo/gameoflife/branches{/branch}","tags_url":"https://api.github.com/repos/himanshuo/gameoflife/tags","blobs_url":"https://api.github.com/repos/himanshuo/gameoflife/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/himanshuo/gameoflife/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/himanshuo/gameoflife/git/refs{/sha}","trees_url":"https://api.github.com/repos/himanshuo/gameoflife/git/trees{/sha}","statuses_url":"https://api.github.com/repos/himanshuo/gameoflife/statuses/{sha}","languages_url":"https://api.github.com/repos/himanshuo/gameoflife/languages","stargazers_url":"https://api.github.com/repos/himanshuo/gameoflife/stargazers","contributors_url":"https://api.github.com/repos/himanshuo/gameoflife/contributors","subscribers_url":"https://api.github.com/repos/himanshuo/gameoflife/subscribers","subscription_url":"https://api.github.com/repos/himanshuo/gameoflife/subscription","commits_url":"https://api.github.com/repos/himanshuo/gameoflife/commits{/sha}","git_commits_url":"https://api.github.com/repos/himanshuo/gameoflife/git/commits{/sha}","comments_url":"https://api.github.com/repos/himanshuo/gameoflife/comments{/number}","issue_comment_url":"https://api.github.com/repos/himanshuo/gameoflife/issues/comments{/number}","contents_url":"https://api.github.com/repos/himanshuo/gameoflife/contents/{+path}","compare_url":"https://api.github.com/repos/himanshuo/gameoflife/compare/{base}...{head}","merges_url":"https://api.github.com/repos/himanshuo/gameoflife/merges","archive_url":"https://api.github.com/repos/himanshuo/gameoflife/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/himanshuo/gameoflife/downloads","issues_url":"https://api.github.com/repos/himanshuo/gameoflife/issues{/number}","pulls_url":"https://api.github.com/repos/himanshuo/gameoflife/pulls{/number}","milestones_url":"https://api.github.com/repos/himanshuo/gameoflife/milestones{/number}","notifications_url":"https://api.github.com/repos/himanshuo/gameoflife/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/himanshuo/gameoflife/labels{/name}","releases_url":"https://api.github.com/repos/himanshuo/gameoflife/releases{/id}","created_at":"2015-11-10T15:48:04Z","updated_at":"2015-11-21T13:47:55Z","pushed_at":"2015-11-27T17:07:47Z","git_url":"git://github.com/himanshuo/gameoflife.git","ssh_url":"git@github.com:himanshuo/gameoflife.git","clone_url":"https://github.com/himanshuo/gameoflife.git","svn_url":"https://github.com/himanshuo/gameoflife","homepage":null,"size":1476,"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":27,"forks":0,"open_issues":27,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/himanshuo/gameoflife/pulls/17"},"html":{"href":"https://github.com/himanshuo/gameoflife/pull/17"},"issue":{"href":"https://api.github.com/repos/himanshuo/gameoflife/issues/17"},"comments":{"href":"https://api.github.com/repos/himanshuo/gameoflife/issues/17/comments"},"review_comments":{"href":"https://api.github.com/repos/himanshuo/gameoflife/pulls/17/comments"},"review_comment":{"href":"https://api.github.com/repos/himanshuo/gameoflife/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/himanshuo/gameoflife/pulls/17/commits"},"statuses":{"href":"https://api.github.com/repos/himanshuo/gameoflife/statuses/8431b6ae86d26aae19ab95ef57630b8a0f77e276"}}}}