{"action":"created","issue":{"url":"https://api.github.com/repos/clipperhouse/gen/issues/82","labels_url":"https://api.github.com/repos/clipperhouse/gen/issues/82/labels{/name}","comments_url":"https://api.github.com/repos/clipperhouse/gen/issues/82/comments","events_url":"https://api.github.com/repos/clipperhouse/gen/issues/82/events","html_url":"https://github.com/clipperhouse/gen/issues/82","id":62682278,"number":82,"title":"so many files","user":{"login":"awalterschulze","id":1829933,"avatar_url":"https://avatars.githubusercontent.com/u/1829933?v=3","gravatar_id":"","url":"https://api.github.com/users/awalterschulze","html_url":"https://github.com/awalterschulze","followers_url":"https://api.github.com/users/awalterschulze/followers","following_url":"https://api.github.com/users/awalterschulze/following{/other_user}","gists_url":"https://api.github.com/users/awalterschulze/gists{/gist_id}","starred_url":"https://api.github.com/users/awalterschulze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/awalterschulze/subscriptions","organizations_url":"https://api.github.com/users/awalterschulze/orgs","repos_url":"https://api.github.com/users/awalterschulze/repos","events_url":"https://api.github.com/users/awalterschulze/events{/privacy}","received_events_url":"https://api.github.com/users/awalterschulze/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-03-18T12:29:59Z","updated_at":"2015-03-19T07:33:17Z","closed_at":null,"body":"Hi\r\n\r\nI really like this tool.\r\nI even wrote my own walk typewriter, that would generate the following method.\r\nThis is really useful for Abstract Syntax Trees (ast).\r\n\r\n```\r\nfunc (this *MyType) Walk(v interface {\r\n\tVisit(v interface{}) interface{}\r\n}) {\r\n\tv = v.Visit(this).(interface {\r\n\t\tVisit(v interface{}) interface{}\r\n\t})\r\n\tif this.MyField != nil {\r\n\t\tthis.MyField.Walk(v)\r\n\t}\r\n}\r\n```\r\n\r\nIt is a little ugly, because of the embedded interface.\r\nWhat you would actually want is:\r\n```\r\ntype Visitor interface {\r\n  Walk(v interface{}) Visitor\r\n}\r\n\r\nfunc (this *MyType) Walk(v Visitor) {\r\n        v := v.Visit(this)\r\n        if  this.MyField != nil {\r\n\t\tthis.MyField.Walk(v)\r\n\t}\r\n}\r\n```\r\nBut then everyone would have to import this type.\r\nBut lets not digress.\r\n\r\nI now find that I just generated about 20 files each containing only this one method.\r\nWould it be possible to have all gen code in one file or one file per typewriter or a command line option to do so?\r\n\r\nI don't mind doing the work.\r\nWould you be interested in such a pull request?\r\n"},"comment":{"url":"https://api.github.com/repos/clipperhouse/gen/issues/comments/83385152","html_url":"https://github.com/clipperhouse/gen/issues/82#issuecomment-83385152","issue_url":"https://api.github.com/repos/clipperhouse/gen/issues/82","id":83385152,"user":{"login":"awalterschulze","id":1829933,"avatar_url":"https://avatars.githubusercontent.com/u/1829933?v=3","gravatar_id":"","url":"https://api.github.com/users/awalterschulze","html_url":"https://github.com/awalterschulze","followers_url":"https://api.github.com/users/awalterschulze/followers","following_url":"https://api.github.com/users/awalterschulze/following{/other_user}","gists_url":"https://api.github.com/users/awalterschulze/gists{/gist_id}","starred_url":"https://api.github.com/users/awalterschulze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/awalterschulze/subscriptions","organizations_url":"https://api.github.com/users/awalterschulze/orgs","repos_url":"https://api.github.com/users/awalterschulze/repos","events_url":"https://api.github.com/users/awalterschulze/events{/privacy}","received_events_url":"https://api.github.com/users/awalterschulze/received_events","type":"User","site_admin":false},"created_at":"2015-03-19T07:33:17Z","updated_at":"2015-03-19T07:33:17Z","body":"I was testing it on an ast for a query language so about twenty types.\n\nWe use a LOT of go and have MANY other packages with MANY other types.\nI suspect we could also generate much more of the code than we currently do.\nI think using golang/types is a great way to do that.\nAnd your tool which you built on top of that is almost exactly what I want.\nI only need to generate less files, because it becomes hard to spot the\nfiles with actual code between all the generated files.\n\nI think it should be pretty easy to support both one file mode and one file\nper-type-per-typewriter mode or are you set on only supporting the one file\nper-type-per-typewriter mode?\n\n\n\n\nOn 18 March 2015 at 20:59, Matt Sherman <notifications@github.com> wrote:\n\n> It’s designed to generate one file per-type-per-typewriter. I think that’s\n> a decent way to do it. How many types are you working with here?\n>\n> —\n> Reply to this email directly or view it on GitHub\n> <https://github.com/clipperhouse/gen/issues/82#issuecomment-83122466>.\n>\n"}}