shared

package
v1.23.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const Program = "mkunion"

Variables

This section is empty.

Functions

func Comment

func Comment(g *ast.CommentGroup) string

Comment implementation was copied from func (g *CommentGroup) Text() string and reduced return all comments lines. In contrast to original implementation that skips declaration comments like "//go:generate" which is important for inferring union types.

func FullTypeName added in v1.21.0

func FullTypeName(x reflect.Type) string

func JSONIsNativePath added in v1.21.0

func JSONIsNativePath(x any) bool

func JSONListFromSerializer added in v1.20.1

func JSONListFromSerializer[A any](x []A, serialize func(x A) ([]byte, error)) ([]byte, error)

func JSONMapFromSerializer added in v1.20.1

func JSONMapFromSerializer[K comparable, A any](
	x map[K]A,
	serialize func(x A) ([]byte, error),
) ([]byte, error)

func JSONMarshal added in v1.21.0

func JSONMarshal[A any](x any) ([]byte, error)

func JSONMarshalMap added in v1.21.0

func JSONMarshalMap[T1, T2 any](k T1, v T2) (string, json.RawMessage, error)

func JSONMarshallerRegister added in v1.21.0

func JSONMarshallerRegister[A any](
	fullName string,
	from func([]byte) (A, error),
	to func(A) ([]byte, error),
)

func JSONParseList added in v1.21.0

func JSONParseList(x []byte, onElement func(index int, value []byte) error) error

func JSONParseObject added in v1.20.1

func JSONParseObject(x []byte, onElement func(key string, value []byte) error) error

func JSONToListWithDeserializer added in v1.20.1

func JSONToListWithDeserializer[A any](x []byte, _ []A, deserialize func(value []byte) (A, error)) ([]A, error)

func JSONToMapWithDeserializer added in v1.20.1

func JSONToMapWithDeserializer[K comparable, A any](
	x []byte,
	_ map[K]A,
	deserialize func(value []byte) (A, error),
) (map[K]A, error)

func JSONUnmarshal added in v1.21.0

func JSONUnmarshal[A any](data []byte) (A, error)

func JSONUnmarshalMap added in v1.21.0

func JSONUnmarshalMap[T1, T2 any](key string, value json.RawMessage) (T1, T2, error)

func TypeRegistryLoad added in v1.21.0

func TypeRegistryLoad(typeFullName string) (any, bool)

func TypeRegistryLoadFromReflect added in v1.21.0

func TypeRegistryLoadFromReflect(x reflect.Type) (any, bool)

Types

This section is empty.

Jump to

Keyboard shortcuts

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