Documentation ¶
Overview ¶
Package goutilh provides functions for generating Go code. It can be used in utilities for go:generate, such as including any file at compile time into project as []byte or duplicate existing Go code with some modification (some kind of generics/macros).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteBytes ¶
WriteBytes convert given slice of bytes to GoLang source code representation and write it to given io.Writer. Result will be representation of array type if passed array is true. Otherwise representation will be of type slice. Example: for b=[]byte{1, 2, 3} WriteBytesStr will write "[]byte{1, 2, 3}" AS STRING if array is false and "[3]byte{1, 2, 3}" if array is true. This function may be useful with "//go:generate" directive to include some (binary) files into app at compile time. There are 2 different implementations of this function: using "go/asth" and generating representation "by hand". WriteBytes decides at runtime which implementation to use depending on len(b).
func WriteBytesAst ¶
WriteBytesAst is Ast (see go/asth) implementation of WriteBytes. It should generate proper code even if minor changes in language will happened, but its speed and resource consumption is poor.
Types ¶
This section is empty.