convert

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package convert provides a function to generate conversion functions for a vehicle struct.

Index

Constants

View Source
const (
	// DefaultConversionFile is the default name of the conversion file.
	DefaultConversionFile = "convert-funcs_gen.go"
)

Variables

This section is empty.

Functions

func Generate

func Generate(tmplData *schema.TemplateData, cfg Config) (err error)

Generate creates a conversion functions for each field of a model struct. as well as the entire model struct.

func GetDeclaredFunctions added in v0.3.0

func GetDeclaredFunctions(outputPath string) (map[string]FunctionInfo, error)

GetDeclaredFunctions returns a map of function names to their corresponding function information for a given directory. The function information includes comments and body.

Types

type Config

type Config struct {
	// CopyComments determines if comments for the conversion functions should be copied through.
	CopyComments bool
	// OutputFile is the output directory for the generated conversion files.
	// if empty, the base output directory is used.
	OutputFile string
	// PackageName is the name of the package to generate the conversion functions.
	PackageName string
}

Config is the configuration for the conversion generator.

type FunctionInfo added in v0.3.0

type FunctionInfo struct {
	Comments string
	Body     []byte
}

Jump to

Keyboard shortcuts

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