News for hackers. Stuff that matters.
Re:Go generate: A proposal for a Go preprocessor by pcl on Saturday September 27, 2014 @06:20AM (#8376626)
the author commits the generated files to the source repository, so that they are available to clients that use go get

Treating generated files as primary source is a disaster waiting to happen. Someone will end up just doing a quick edit of the derived file because yacc isn't set up right, or running a sed command to do a refactoring, or just not understand the difference. One of the things that I like about go is that it does a good job of keeping the codebase clean; recommending a solution that sets up this sort of trap is a big departure.

I wonder what other approaches are available for packages that intend to distribute in source form, however. I could imagine adding a parallel directory structure for the generated files, to make it clear that they are out of bounds, akin to the mvn source / target layout.

Re:Go generate: A proposal for a Go preprocessor by mrweasel on Saturday September 27, 2014 @07:15AM (#8376704)
I completely agree. If you're going to add generated files to a source code repository, they need to be clearly marked in one way or another.

If the author truly want a "go generate" they good sell it much better. I understand the yacc idea, it can be a pretty good solution for something like configuration files. OpenBSD use yacc to do the grammar for many of they tools and that has worked out create.

The big sell though would be WSDLs. I understand the aversion towards SOAP and WSDL, but it's here and having Go support would be nice. Generating Go code from a WSDL wouldn't be to hard a sell I think, and it fits nicely into this idea.

Re:Go generate: A proposal for a Go preprocessor by iand on Saturday September 27, 2014 @07:53AM (#8376756)
I think you misunderstand the context. go generate is already in Go tip and will be released as part of Go 1.4
Re:Go generate: A proposal for a Go preprocessor by pcl on Saturday September 27, 2014 @08:06AM (#8376781)
Thanks; good to know. Here's a link to the original discussion thread on the Go newsgroup from July: https://groups.google.com/forum/#!topic/golang-dev/ZTD1qtpru...
Re:Go generate: A proposal for a Go preprocessor by NateDad on Saturday September 27, 2014 @01:10PM (#8377543)
Actually it's not really a big deal. You just put a header at the top that tells people not to hand modify it. Every C# winforms project already did that.

The nice thing is that you can diff the newly generated code versus the old code and make sure changes make sense.