On Thu, Apr 16, 2015 at 6:00 PM, 'Matthew Dempsky' via golang-dev
<
golan...@googlegroups.com> wrote:
> Currently compress/flate has two copies of the Huffman decoder
> initialization code, one for package flate and one for the (package main)
> helper generator. I want to deduplicate that code by moving it into a
> helper package compress/flate/internal/huffman.
What we do in
golang.org/x/text/cases is:
cases.go has this line:
//go:generate go run gen.go gen_trieval.go
gen_trieval.go is "package main".
gen.go copies gen_trieval.go to trieval.go, substitutes s/main/cases/
and adds a "This file was generated by go generate; DO NOT EDIT"
header.
Thus, there's one human-editable copy of the code (gen_trieval.go),
one generated copy of the code (trieval.go), and we are able to share
code between the package proper and its code generator, all in the one
directory and without an internal side package.