codecgen

package
v0.0.0-...-6f8fa1e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2016 License: Apache-2.0 Imports: 15 Imported by: 0

README

codecgen tool

Generate is given a list of *.go files to parse, and an output file (fout), codecgen will create an output file file.go which contains codec.Selfer implementations for the named types found in the files parsed.

Using codecgen is very straightforward.

Download and install the tool

go get -u github.com/ugorji/go/codec/codecgen

Run the tool on your files

The command line format is:

codecgen [options] (-o outfile) (infile ...)

% codecgen -?
Usage of codecgen:
  -c="github.com/ugorji/go/codec": codec path
  -o="": out file
  -r=".*": regex for type name to match
  -rt="": tags for go run
  -t="": build tag to put in file
  -u=false: Use unsafe, e.g. to avoid unnecessary allocation on []byte->string
  -x=false: keep temp file

% codecgen -o values_codecgen.go values.go values2.go moretypedefs.go

Please see the blog article for more information on how to use the tool.

Documentation

Overview

codecgen generates codec.Selfer implementations for a set of types.

Index

Constants

View Source
const GenCodecPath = "github.com/ugorji/go/codec"

Variables

This section is empty.

Functions

func Generate

func Generate(outfile, buildTag, codecPkgPath string, useUnsafe bool, goRunTag string,
	regexName *regexp.Regexp, deleteTempFile bool, infiles ...string) (err error)

Generate is given a list of *.go files to parse, and an output file (fout).

It finds all types T in the files, and it creates 2 tmp files (frun).

  • main package file passed to 'go run'
  • package level file which calls *genRunner.Selfer to write Selfer impls for each T.

We use a package level file so that it can reference unexported types in the package being worked on. Tool then executes: "go run __frun__" which creates fout. fout contains Codec(En|De)codeSelf implementations for every type T.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL