{"action":"created","comment":{"url":"https://api.github.com/repos/thriftrw/thriftrw-go/pulls/comments/76296924","id":76296924,"diff_hunk":"@@ -0,0 +1,284 @@\n+// Copyright (c) 2016 Uber Technologies, Inc.\n+//\n+// Permission is hereby granted, free of charge, to any person obtaining a copy\n+// of this software and associated documentation files (the \"Software\"), to deal\n+// in the Software without restriction, including without limitation the rights\n+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n+// copies of the Software, and to permit persons to whom the Software is\n+// furnished to do so, subject to the following conditions:\n+//\n+// The above copyright notice and this permission notice shall be included in\n+// all copies or substantial portions of the Software.\n+//\n+// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n+// THE SOFTWARE.\n+\n+package plugin\n+\n+import (\n+\t\"bytes\"\n+\t\"fmt\"\n+\t\"go/parser\"\n+\t\"go/printer\"\n+\t\"go/token\"\n+\t\"sort\"\n+\t\"text/template\"\n+\n+\t\"github.com/thriftrw/thriftrw-go/internal/goast\"\n+\t\"github.com/thriftrw/thriftrw-go/plugin/api\"\n+\n+\t\"golang.org/x/tools/go/ast/astutil\"\n+)\n+\n+// TemplateOption provides optional arguments to GoFileFromTemplate.\n+type TemplateOption struct {\n+\tapply func(*goFileGenerator)\n+}\n+\n+// TemplateFunc is a TemplateOption that makes a function available in the\n+// template.\n+//\n+// The function may be anything accepted by text/template.\n+//\n+// \tGoFileFromTemplate(\n+// \t\tfilename,\n+// \t\t`package <lower \"HELLO\">`,\n+// \t\tTemplateFunc(\"lower\", strings.ToLower),\n+// \t)\n+func TemplateFunc(name string, f interface{}) TemplateOption {\n+\treturn TemplateOption{apply: func(t *goFileGenerator) {\n+\t\tt.funcs[name] = f\n+\t}}\n+}\n+\n+// GoFileImportPath is a TemplateOption that specifies the intended import path","path":"plugin/template.go","position":59,"original_position":59,"commit_id":"c088815f2a411cc1f089be3a87145713390b4639","original_commit_id":"c088815f2a411cc1f089be3a87145713390b4639","user":{"login":"abhinav","id":41730,"avatar_url":"https://avatars.githubusercontent.com/u/41730?v=3","gravatar_id":"","url":"https://api.github.com/users/abhinav","html_url":"https://github.com/abhinav","followers_url":"https://api.github.com/users/abhinav/followers","following_url":"https://api.github.com/users/abhinav/following{/other_user}","gists_url":"https://api.github.com/users/abhinav/gists{/gist_id}","starred_url":"https://api.github.com/users/abhinav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abhinav/subscriptions","organizations_url":"https://api.github.com/users/abhinav/orgs","repos_url":"https://api.github.com/users/abhinav/repos","events_url":"https://api.github.com/users/abhinav/events{/privacy}","received_events_url":"https://api.github.com/users/abhinav/received_events","type":"User","site_admin":false},"body":"Yep. Will clarify in docs.","created_at":"2016-08-25T18:16:32Z","updated_at":"2016-08-25T18:16:32Z","html_url":"https://github.com/thriftrw/thriftrw-go/pull/186#discussion_r76296924","pull_request_url":"https://api.github.com/repos/thriftrw/thriftrw-go/pulls/186","_links":{"self":{"href":"https://api.github.com/repos/thriftrw/thriftrw-go/pulls/comments/76296924"},"html":{"href":"https://github.com/thriftrw/thriftrw-go/pull/186#discussion_r76296924"},"pull_request":{"href":"https://api.github.com/repos/thriftrw/thriftrw-go/pulls/186"}}},"pull_request":{"url":"https://api.github.com/repos/thriftrw/thriftrw-go/pulls/186","id":82632372,"html_url":"https://github.com/thriftrw/thriftrw-go/pull/186","diff_url":"https://github.com/thriftrw/thriftrw-go/pull/186.diff","patch_url":"https://github.com/thriftrw/thriftrw-go/pull/186.patch","issue_url":"https://api.github.com/repos/thriftrw/thriftrw-go/issues/186","number":186,"state":"open","locked":false,"title":"plugin: Add templating system","user":{"login":"abhinav","id":41730,"avatar_url":"https://avatars.githubusercontent.com/u/41730?v=3","gravatar_id":"","url":"https://api.github.com/users/abhinav","html_url":"https://github.com/abhinav","followers_url":"https://api.github.com/users/abhinav/followers","following_url":"https://api.github.com/users/abhinav/following{/other_user}","gists_url":"https://api.github.com/users/abhinav/gists{/gist_id}","starred_url":"https://api.github.com/users/abhinav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abhinav/subscriptions","organizations_url":"https://api.github.com/users/abhinav/orgs","repos_url":"https://api.github.com/users/abhinav/repos","events_url":"https://api.github.com/users/abhinav/events{/privacy}","received_events_url":"https://api.github.com/users/abhinav/received_events","type":"User","site_admin":false},"body":"Plugin authors will be able to use this to generate code using a templating\nsystem similar to what ThriftRW uses internally. This is significantly simpler\nthan what ThriftRW uses internally but should suffice for most use cases.\n\nDepends on #184.\n\n@prashantv @kriskowal @breerly","created_at":"2016-08-24T23:02:42Z","updated_at":"2016-08-25T18:16:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4954ee9de16bae7e0ed3826f8d7cc5dbce908b18","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/thriftrw/thriftrw-go/pulls/186/commits","review_comments_url":"https://api.github.com/repos/thriftrw/thriftrw-go/pulls/186/comments","review_comment_url":"https://api.github.com/repos/thriftrw/thriftrw-go/pulls/comments{/number}","comments_url":"https://api.github.com/repos/thriftrw/thriftrw-go/issues/186/comments","statuses_url":"https://api.github.com/repos/thriftrw/thriftrw-go/statuses/c088815f2a411cc1f089be3a87145713390b4639","head":{"label":"thriftrw:plugin-template","ref":"plugin-template","sha":"c088815f2a411cc1f089be3a87145713390b4639","user":{"login":"thriftrw","id":16569516,"avatar_url":"https://avatars.githubusercontent.com/u/16569516?v=3","gravatar_id":"","url":"https://api.github.com/users/thriftrw","html_url":"https://github.com/thriftrw","followers_url":"https://api.github.com/users/thriftrw/followers","following_url":"https://api.github.com/users/thriftrw/following{/other_user}","gists_url":"https://api.github.com/users/thriftrw/gists{/gist_id}","starred_url":"https://api.github.com/users/thriftrw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thriftrw/subscriptions","organizations_url":"https://api.github.com/users/thriftrw/orgs","repos_url":"https://api.github.com/users/thriftrw/repos","events_url":"https://api.github.com/users/thriftrw/events{/privacy}","received_events_url":"https://api.github.com/users/thriftrw/received_events","type":"Organization","site_admin":false},"repo":{"id":45574831,"name":"thriftrw-go","full_name":"thriftrw/thriftrw-go","owner":{"login":"thriftrw","id":16569516,"avatar_url":"https://avatars.githubusercontent.com/u/16569516?v=3","gravatar_id":"","url":"https://api.github.com/users/thriftrw","html_url":"https://github.com/thriftrw","followers_url":"https://api.github.com/users/thriftrw/followers","following_url":"https://api.github.com/users/thriftrw/following{/other_user}","gists_url":"https://api.github.com/users/thriftrw/gists{/gist_id}","starred_url":"https://api.github.com/users/thriftrw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thriftrw/subscriptions","organizations_url":"https://api.github.com/users/thriftrw/orgs","repos_url":"https://api.github.com/users/thriftrw/repos","events_url":"https://api.github.com/users/thriftrw/events{/privacy}","received_events_url":"https://api.github.com/users/thriftrw/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/thriftrw/thriftrw-go","description":"A Thrift encoding code generator and library for Go","fork":false,"url":"https://api.github.com/repos/thriftrw/thriftrw-go","forks_url":"https://api.github.com/repos/thriftrw/thriftrw-go/forks","keys_url":"https://api.github.com/repos/thriftrw/thriftrw-go/keys{/key_id}","collaborators_url":"https://api.github.com/repos/thriftrw/thriftrw-go/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/thriftrw/thriftrw-go/teams","hooks_url":"https://api.github.com/repos/thriftrw/thriftrw-go/hooks","issue_events_url":"https://api.github.com/repos/thriftrw/thriftrw-go/issues/events{/number}","events_url":"https://api.github.com/repos/thriftrw/thriftrw-go/events","assignees_url":"https://api.github.com/repos/thriftrw/thriftrw-go/assignees{/user}","branches_url":"https://api.github.com/repos/thriftrw/thriftrw-go/branches{/branch}","tags_url":"https://api.github.com/repos/thriftrw/thriftrw-go/tags","blobs_url":"https://api.github.com/repos/thriftrw/thriftrw-go/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/thriftrw/thriftrw-go/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/thriftrw/thriftrw-go/git/refs{/sha}","trees_url":"https://api.github.com/repos/thriftrw/thriftrw-go/git/trees{/sha}","statuses_url":"https://api.github.com/repos/thriftrw/thriftrw-go/statuses/{sha}","languages_url":"https://api.github.com/repos/thriftrw/thriftrw-go/languages","stargazers_url":"https://api.github.com/repos/thriftrw/thriftrw-go/stargazers","contributors_url":"https://api.github.com/repos/thriftrw/thriftrw-go/contributors","subscribers_url":"https://api.github.com/repos/thriftrw/thriftrw-go/subscribers","subscription_url":"https://api.github.com/repos/thriftrw/thriftrw-go/subscription","commits_url":"https://api.github.com/repos/thriftrw/thriftrw-go/commits{/sha}","git_commits_url":"https://api.github.com/repos/thriftrw/thriftrw-go/git/commits{/sha}","comments_url":"https://api.github.com/repos/thriftrw/thriftrw-go/comments{/number}","issue_comment_url":"https://api.github.com/repos/thriftrw/thriftrw-go/issues/comments{/number}","contents_url":"https://api.github.com/repos/thriftrw/thriftrw-go/contents/{+path}","compare_url":"https://api.github.com/repos/thriftrw/thriftrw-go/compare/{base}...{head}","merges_url":"https://api.github.com/repos/thriftrw/thriftrw-go/merges","archive_url":"https://api.github.com/repos/thriftrw/thriftrw-go/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/thriftrw/thriftrw-go/downloads","issues_url":"https://api.github.com/repos/thriftrw/thriftrw-go/issues{/number}","pulls_url":"https://api.github.com/repos/thriftrw/thriftrw-go/pulls{/number}","milestones_url":"https://api.github.com/repos/thriftrw/thriftrw-go/milestones{/number}","notifications_url":"https://api.github.com/repos/thriftrw/thriftrw-go/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/thriftrw/thriftrw-go/labels{/name}","releases_url":"https://api.github.com/repos/thriftrw/thriftrw-go/releases{/id}","deployments_url":"https://api.github.com/repos/thriftrw/thriftrw-go/deployments","created_at":"2015-11-04T23:43:00Z","updated_at":"2016-07-28T17:18:44Z","pushed_at":"2016-08-25T17:27:32Z","git_url":"git://github.com/thriftrw/thriftrw-go.git","ssh_url":"git@github.com:thriftrw/thriftrw-go.git","clone_url":"https://github.com/thriftrw/thriftrw-go.git","svn_url":"https://github.com/thriftrw/thriftrw-go","homepage":"","size":825,"stargazers_count":8,"watchers_count":8,"language":"Go","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":8,"default_branch":"master"}},"base":{"label":"thriftrw:plugin-idl","ref":"plugin-idl","sha":"47c9f1014e341578005591694dabccb5108f5f3d","user":{"login":"thriftrw","id":16569516,"avatar_url":"https://avatars.githubusercontent.com/u/16569516?v=3","gravatar_id":"","url":"https://api.github.com/users/thriftrw","html_url":"https://github.com/thriftrw","followers_url":"https://api.github.com/users/thriftrw/followers","following_url":"https://api.github.com/users/thriftrw/following{/other_user}","gists_url":"https://api.github.com/users/thriftrw/gists{/gist_id}","starred_url":"https://api.github.com/users/thriftrw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thriftrw/subscriptions","organizations_url":"https://api.github.com/users/thriftrw/orgs","repos_url":"https://api.github.com/users/thriftrw/repos","events_url":"https://api.github.com/users/thriftrw/events{/privacy}","received_events_url":"https://api.github.com/users/thriftrw/received_events","type":"Organization","site_admin":false},"repo":{"id":45574831,"name":"thriftrw-go","full_name":"thriftrw/thriftrw-go","owner":{"login":"thriftrw","id":16569516,"avatar_url":"https://avatars.githubusercontent.com/u/16569516?v=3","gravatar_id":"","url":"https://api.github.com/users/thriftrw","html_url":"https://github.com/thriftrw","followers_url":"https://api.github.com/users/thriftrw/followers","following_url":"https://api.github.com/users/thriftrw/following{/other_user}","gists_url":"https://api.github.com/users/thriftrw/gists{/gist_id}","starred_url":"https://api.github.com/users/thriftrw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thriftrw/subscriptions","organizations_url":"https://api.github.com/users/thriftrw/orgs","repos_url":"https://api.github.com/users/thriftrw/repos","events_url":"https://api.github.com/users/thriftrw/events{/privacy}","received_events_url":"https://api.github.com/users/thriftrw/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/thriftrw/thriftrw-go","description":"A Thrift encoding code generator and library for Go","fork":false,"url":"https://api.github.com/repos/thriftrw/thriftrw-go","forks_url":"https://api.github.com/repos/thriftrw/thriftrw-go/forks","keys_url":"https://api.github.com/repos/thriftrw/thriftrw-go/keys{/key_id}","collaborators_url":"https://api.github.com/repos/thriftrw/thriftrw-go/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/thriftrw/thriftrw-go/teams","hooks_url":"https://api.github.com/repos/thriftrw/thriftrw-go/hooks","issue_events_url":"https://api.github.com/repos/thriftrw/thriftrw-go/issues/events{/number}","events_url":"https://api.github.com/repos/thriftrw/thriftrw-go/events","assignees_url":"https://api.github.com/repos/thriftrw/thriftrw-go/assignees{/user}","branches_url":"https://api.github.com/repos/thriftrw/thriftrw-go/branches{/branch}","tags_url":"https://api.github.com/repos/thriftrw/thriftrw-go/tags","blobs_url":"https://api.github.com/repos/thriftrw/thriftrw-go/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/thriftrw/thriftrw-go/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/thriftrw/thriftrw-go/git/refs{/sha}","trees_url":"https://api.github.com/repos/thriftrw/thriftrw-go/git/trees{/sha}","statuses_url":"https://api.github.com/repos/thriftrw/thriftrw-go/statuses/{sha}","languages_url":"https://api.github.com/repos/thriftrw/thriftrw-go/languages","stargazers_url":"https://api.github.com/repos/thriftrw/thriftrw-go/stargazers","contributors_url":"https://api.github.com/repos/thriftrw/thriftrw-go/contributors","subscribers_url":"https://api.github.com/repos/thriftrw/thriftrw-go/subscribers","subscription_url":"https://api.github.com/repos/thriftrw/thriftrw-go/subscription","commits_url":"https://api.github.com/repos/thriftrw/thriftrw-go/commits{/sha}","git_commits_url":"https://api.github.com/repos/thriftrw/thriftrw-go/git/commits{/sha}","comments_url":"https://api.github.com/repos/thriftrw/thriftrw-go/comments{/number}","issue_comment_url":"https://api.github.com/repos/thriftrw/thriftrw-go/issues/comments{/number}","contents_url":"https://api.github.com/repos/thriftrw/thriftrw-go/contents/{+path}","compare_url":"https://api.github.com/repos/thriftrw/thriftrw-go/compare/{base}...{head}","merges_url":"https://api.github.com/repos/thriftrw/thriftrw-go/merges","archive_url":"https://api.github.com/repos/thriftrw/thriftrw-go/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/thriftrw/thriftrw-go/downloads","issues_url":"https://api.github.com/repos/thriftrw/thriftrw-go/issues{/number}","pulls_url":"https://api.github.com/repos/thriftrw/thriftrw-go/pulls{/number}","milestones_url":"https://api.github.com/repos/thriftrw/thriftrw-go/milestones{/number}","notifications_url":"https://api.github.com/repos/thriftrw/thriftrw-go/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/thriftrw/thriftrw-go/labels{/name}","releases_url":"https://api.github.com/repos/thriftrw/thriftrw-go/releases{/id}","deployments_url":"https://api.github.com/repos/thriftrw/thriftrw-go/deployments","created_at":"2015-11-04T23:43:00Z","updated_at":"2016-07-28T17:18:44Z","pushed_at":"2016-08-25T17:27:32Z","git_url":"git://github.com/thriftrw/thriftrw-go.git","ssh_url":"git@github.com:thriftrw/thriftrw-go.git","clone_url":"https://github.com/thriftrw/thriftrw-go.git","svn_url":"https://github.com/thriftrw/thriftrw-go","homepage":"","size":825,"stargazers_count":8,"watchers_count":8,"language":"Go","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":8,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/thriftrw/thriftrw-go/pulls/186"},"html":{"href":"https://github.com/thriftrw/thriftrw-go/pull/186"},"issue":{"href":"https://api.github.com/repos/thriftrw/thriftrw-go/issues/186"},"comments":{"href":"https://api.github.com/repos/thriftrw/thriftrw-go/issues/186/comments"},"review_comments":{"href":"https://api.github.com/repos/thriftrw/thriftrw-go/pulls/186/comments"},"review_comment":{"href":"https://api.github.com/repos/thriftrw/thriftrw-go/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/thriftrw/thriftrw-go/pulls/186/commits"},"statuses":{"href":"https://api.github.com/repos/thriftrw/thriftrw-go/statuses/c088815f2a411cc1f089be3a87145713390b4639"}}}}
{"actor":{"display_login":"abhinav"}}