wrappergen

package module
v0.0.0-...-235f5fe Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2022 License: Apache-2.0 Imports: 18 Imported by: 2

README

wrappergen is a library to enable generation of wrappers around binapi from Go templates.

Quickstart

You can start a simple wrappergen project by simply adding a gen.go file to your package:

//go:build tools

package main

import (
	_ "github.com/edwarnicke/wrappergen/cmd"
)

// Run using go generate -tags tools ./...
//go:generate go run github.com/edwarnicke/wrappergen/cmd"

and running:

go generate -tags tools ./...

which will generate a main.go file.

Create a subdirectory templates/ and start adding *.go.tmpl files to it. Your code generator can then be trivially consumed by downstream user with a gen.go file like:

//go:build tools

package vpplink

import (
	_ "github.com/edwarnicke/vpplink/cmd"
	_ "go.fd.io/govpp/binapi"
)

// Run using go generate -tags tools ./...
//go:generate go run github.com/edwarnicke/vpplink/cmd --binapi-package "go.fd.io/govpp/binapi"

substituting your code generator in place of "github.com/edwarnicke/vpplink/cmd" in the above example.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Data

type Data struct {
	BinAPI        string
	PackageName   string
	PackagePrefix string
	// contains filtered or unexported fields
}

func NewData

func NewData(binAPIPackage, packageName, outputDir string) (*Data, error)

NewData creates a new Data struct

binAPIPackage - the golang package for the binapi being used
                Example: "git.fd.io/govpp.git/binapi"
packageName - the short package name for use in generated templates.  Example: vpplink
outputDir - the directory to which generated code should be output

func (*Data) RequirementSatisfied

func (d *Data) RequirementSatisfied(reqs ...string) bool

type Template

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

func ParseFS

func ParseFS(input fs.FS, patterns ...string) (*Template, error)

func (*Template) ExecuteAll

func (t *Template) ExecuteAll(outputDir string, data interface{}) error

Directories

Path Synopsis
cmd
_templates
Code generated by github.com/edwarnicke/wrappergen DO NOT EDIT.
Code generated by github.com/edwarnicke/wrappergen DO NOT EDIT.

Jump to

Keyboard shortcuts

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