package genfunc

import "cuelang.org/go/internal/filetypes/internal/genfunc"

Index

Functions

func GenerateGoFuncForCUEStruct

func GenerateGoFuncForCUEStruct(buf *bytes.Buffer, funcName, structName string, e cue.Value, keys []string, typeName string)

GenerateGoFuncForCUEStruct writes to buf a function definition that will unify a Go struct as defined by GenerateGoTypeForFields with the given CUE value, of the form:

func funcName(t typeName) (typeName, error)

It only understands an extremely limited subset of CUE, as driven by the usage inside internal/filetypes/types.cue: - no cyclic dependencies - only a single scalar type for all fields in the struct - all fields are known ahead of time

and many more restrictions. It should fail when the CUE falls outside those restrictions.

func GenerateGoTypeForFields

func GenerateGoTypeForFields(buf *bytes.Buffer, structName string, fields []string, memberType string)

GenerateGoTypeForFields writes to buf a definition for a Go struct type named structName with the given field names, all of which are of the same member type. It also generates unmarshalFromMap and marshalToMap methods to convert to and from map[string]memberType values.

Source Files

gen.go simplify.go

Version
v0.13.0-rc.1
Published
May 16, 2025
Platform
linux/amd64
Imports
10 packages
Last checked
1 hour ago

Tools for package owners.