func (w *CodeWriter) WriteGo(out io.Writer, pkg, tags string) (n int, err error) {
	sz := w.Size
	if sz > 0 {
		w.WriteComment("Total table size %d bytes (%dKiB); checksum: %X\n", sz, sz/1024, w.Hash.Sum32())
	}
	defer w.buf.Reset()
	return WriteGo(out, pkg, tags, w.buf.Bytes())
}
WriteGo appends the buffer with the total size of all created structures and
writes it as a Go file to the given writer with the given package name.
package gen
import (
	"bytes"
	"encoding/gob"
	"fmt"
	"hash"
	"hash/fnv"
	"io"
	"log"
	"os"
	"reflect"
	"strings"
	"unicode"
	"unicode/utf8"
)
type CodeWriter struct {
	buf  bytes.Buffer
	Size int
	Hash hash.Hash32  
	gob  *gob.Encoder
	skipSep bool
}
func (w *CodeWriter) Write(p []byte) (n int, err error) {
	return w.buf.Write(p)
}
func NewCodeWriter() *CodeWriter {
	h := fnv.New32()
	return &CodeWriter{Hash: h, gob: gob.NewEncoder(h)}
}
func (w *CodeWriter) WriteGoFile(filename, pkg string) {
	f, err := os.Create(filename)
	if err != nil {
		log.Fatalf("Could not create file %s: %v", filename, err)
	}
	defer f.Close()
	if _, err = w.WriteGo(f, pkg, ""); err != nil {
		log.Fatalf("Error writing file %s: %v", filename, err)
	}
}
func (w *CodeWriter) WriteVersionedGoFile(filename, pkg string) {
	tags := buildTags()
	if tags != "" {
		pattern := fileToPattern(filename)
		updateBuildTags(pattern)
		filename = fmt.Sprintf(pattern, UnicodeVersion())
	}
	f, err := os.Create(filename)
	if err != nil {
		log.Fatalf("Could not create file %s: %v", filename, err)
	}
	defer f.Close()
	if _, err = w.WriteGo(f, pkg, tags); err != nil {
		log.Fatalf("Error writing file %s: %v", filename, err)
	}
}