bindgen

package
v0.0.0-...-4e16d91 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package bindgen generates Go source code from a fully-resolved WIT package. It generates one or more Go packages, with functions, types, constants, and variables, along with the associated code to lift and lower Go types into Canonical ABI representation.

Index

Constants

View Source
const (
	GoSuffix     = ".wit.go"
	BuildDefault = "!wasip1"
)

Variables

View Source
var ExportedSegments = map[string]string{
	"datetime": "DateTime",
	"filesize": "FileSize",
	"ipv4":     "IPv4",
	"ipv6":     "IPv6",
	"readlink": "ReadLink",
}

ExportedSegments maps common WASI identifier segments to opinionated exported Go equivalents.

View Source
var Segments = map[string]string{
	"datetime": "dateTime",
	"filesize": "fileSize",
	"readlink": "readLink",
}

Segments maps common WASI identifier segments to opinionated non-exported Go equivalents.

Functions

func FlatName

func FlatName(name string) string

FlatName returns a flat equivalent of a WIT name, where the segments are joined together with no delimiter. It may conflict with a Go keyword or predeclared identifier.

func Go

func Go(res *wit.Resolve, opts ...Option) ([]*gen.Package, error)

Go generates one or more Go packages from wit.Resolve res. It returns any error that occurs during code generation.

func GoName

func GoName(name string, export bool) string

GoName returns an idiomatic (exported CamelCase) Go name for a WIT name.

func GoPackageName

func GoPackageName(name string) string

GoPackageName generates a Go local package name (e.g. "json").

func SnakeName

func SnakeName(name string) string

SnakeName returns a snake_case equivalent of a WIT name. It may conflict with a Go keyword or predeclared identifier.

Types

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option represents a single configuration option for this package.

func CMPackage

func CMPackage(path string) Option

CMPackage returns an Option that specifies the package path to the Component Model utility package (default: github.com/ydnar/wasm-tools-go/cm).

func GeneratedBy

func GeneratedBy(name string) Option

GeneratedBy returns an Option that specifies the name of the program or package that will appear in the "Code generated by ..." header on generated files.

func PackageRoot

func PackageRoot(path string) Option

PackageRoot returns an Option that specifies the root Go package path for generated Go packages.

func Versioned

func Versioned(versioned bool) Option

Versioned returns an Option that specifies that all generated Go packages will have versions that match WIT versions.

func World

func World(world string) Option

World returns an Option that specifies the WIT world to generate.

Jump to

Keyboard shortcuts

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