bavard

package module
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2022 License: Apache-2.0 Imports: 16 Imported by: 10

README

bavard

Internal package with some code-generation helper (txt/template and asm).

Used by:

Documentation

Overview

Package bavard contains helper functions to generate consistent code from text/template templates. it is used by github.com/consensys/gnark && github.com/consensys/gnark-crypto

Index

Constants

This section is empty.

Variables

View Source
var StringBuilderPool = sync.Pool{New: func() interface{} { return &strings.Builder{} }}

Functions

func Apache2

func Apache2(copyrightHolder string, year int) func(*Bavard) error

Apache2 returns a bavard option to be used in Generate writing an apache2 licence header in the generated file

func Apache2Header added in v0.1.6

func Apache2Header(copyrightHolder string, year int) string

Apache2Header returns a Apache2 header string

func AssertSlice added in v0.1.11

func AssertSlice(input interface{}) (reflect.Value, error)

func BuildTag added in v0.1.1

func BuildTag(buildTag string) func(*Bavard) error

BuildTag returns a bavard option to be used in Generate adding build tags string on top of the generated file

func Format

func Format(v bool) func(*Bavard) error

Format returns a bavard option to be used in Generate. If set to true, will run gofmt on generated file. Or simple tab alignment on .s files

func Funcs added in v0.1.1

func Funcs(funcs template.FuncMap) func(*Bavard) error

Funcs returns a bavard option to be used in Generate. See text/template FuncMap for more info

func GenerateFromFiles added in v0.1.8

func GenerateFromFiles(output string, templateF []string, data interface{}, options ...func(*Bavard) error) error

GenerateFromFiles will concatenate templates and create output file from executing the resulting text/template see other package functions to add options (package name, licensing, build tags, ...)

func GenerateFromString added in v0.1.8

func GenerateFromString(output string, templates []string, data interface{}, options ...func(*Bavard) error) error

GenerateFromString will concatenate templates and create output file from executing the resulting text/template see other package functions to add options (package name, licensing, build tags, ...)

func GeneratedBy

func GeneratedBy(label string) func(*Bavard) error

GeneratedBy returns a bavard option to be used in Generate writing a standard "Code generated by 'label' DO NOT EDIT"

func Import

func Import(v bool) func(*Bavard) error

Import returns a bavard option to be used in Generate. If set to true, will run goimports

func Package

func Package(name string) func(*Bavard) error

Package returns a bavard option adding package name and optional package documentation in the generated file

func Verbose

func Verbose(v bool) func(*Bavard) error

Verbose returns a bavard option to be used in Generate. If set to true, will print to stdout during code generation

func WriteBigIntAsUint64Slice added in v0.1.12

func WriteBigIntAsUint64Slice(builder *strings.Builder, input *big.Int)

Types

type BatchGenerator added in v0.1.7

type BatchGenerator struct {
	// contains filtered or unexported fields
}

BatchGenerator enables more efficient and clean multiple file generation

func NewBatchGenerator added in v0.1.7

func NewBatchGenerator(copyrightHolder string, copyrightYear int, generatedBy string) *BatchGenerator

NewBatchGenerator returns a new BatchGenerator

func (*BatchGenerator) Generate added in v0.1.7

func (b *BatchGenerator) Generate(data interface{}, packageName string, baseTmplDir string, entries ...Entry) error

Generate an entry with generator default config

func (*BatchGenerator) GenerateWithOptions added in v0.1.12

func (b *BatchGenerator) GenerateWithOptions(data interface{}, packageName string, baseTmplDir string, extraOptions []func(*Bavard) error, entries ...Entry) error

GenerateWithOptions allows adding extra configuration (helper functions etc.) to a batch generation

type Bavard

type Bavard struct {
	// contains filtered or unexported fields
}

Bavard root object to configure the code generation from text/template

type Entry added in v0.1.7

type Entry struct {
	File      string
	Templates []string
	BuildTag  string
}

Entry to be used in batch generation of files

Directories

Path Synopsis
Package amd64 contains wrapper to amd64 instructions in Go assembly.
Package amd64 contains wrapper to amd64 instructions in Go assembly.

Jump to

Keyboard shortcuts

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