generator

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

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultValueAsString

func DefaultValueAsString(t types.Type, config Config) (string, error)

DefaultValueAsString generates the default value for a given types.Type and returns it as a string.

func FailErr

func FailErr(err error)

FailErr prints the error and exits the program.

func FindAbsolutePathFromRelative

func FindAbsolutePathFromRelative(relativePath string) string

FindAbsolutePathFromRelative finds the absolute path from a relative path.

func FindFirstLetterIndex

func FindFirstLetterIndex(input string) int

FindFirstLetterIndex is a helper function to find the index of the first letter in a string.

func FlattenType

func FlattenType(typ types.Type) types.Type

FlattenType recursively expands composite types until primitive types are reached.

func GenerateClientConAndDisconnMethod

func GenerateClientConAndDisconnMethod(
	generatorConfig Config,
) jen.Code

GenerateClientConAndDisconnMethod generates the connect and disconnect methods for the client.

func GenerateClientMethods

func GenerateClientMethods(
	generatorConfig Config,
) jen.Code

GenerateClientMethods generates the RPC methods for the client.

func GenerateForInterface

func GenerateForInterface(
	config InitConfig,
) error

GenerateServiceMethods generates the RPC methods for the service.

func GenerateMainStruct

func GenerateMainStruct(
	generatorConfig Config,
) jen.Code

GenerateMainStruct generates the main struct for the service and client.

func GenerateServiceMethods

func GenerateServiceMethods(
	generatorConfig Config,
) jen.Code

GenerateServiceMethods generates the service methods.

func GenerateServiceMethodsSwitchCase

func GenerateServiceMethodsSwitchCase(
	config Config,
	method *types.Func,
	stmt *jen.Statement,
)

GenerateServiceMethodsSwitchCase generates the switch cases to handle different message types.

func GenerateStartAndStopServiceMethod

func GenerateStartAndStopServiceMethod(
	generatorConfig Config,
) jen.Code

Generate the start and stop service methods.

func GetPackageInfo

func GetPackageInfo(typ types.Type) (string, string)

GetPackageInfo returns the full import path and package name of a given type.

func GetPathAndQualifiedName

func GetPathAndQualifiedName(sourceType string, config Config) (string, string)

GetPathAndQualifiedName returns the package path and type name of a given type.

func IsGobSerializable

func IsGobSerializable(interfaceType *types.Interface) bool

IsGobSerializable checks if all methods of the given interface type only contain data that's serializable by encoding/gob.

func IsGobType

func IsGobType(typ types.Type) bool

IsGobType checks if the given type is serializable by encoding/gob.

func IsNamedType

func IsNamedType(t types.Type, path, name string) bool

isNamedType reports whether t is the named type path.name.

func ListImplementations

func ListImplementations(
	interfacePkgs []*packages.Package,
	interfaceName string,
) ([]types.Type, error)

ListImplementations returns a list of types that implement the given interface.

func LoadPackage

func LoadPackage(path string) *packages.Package

LoadPackage loads the package and returns the package.

func LoadRepository

func LoadRepository() ([]*packages.Package, error)

LoadRepository loads the repository and returns the packages.

func RequiresQual

func RequiresQual(sourceType string) bool

RequiresQual determines if the source type requires a qualified name.

func SplitSourceType

func SplitSourceType(sourceType string) (string, string)

SplitSourceType splits the source type into package and type name.

Types

type Config

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

type InitConfig

type InitConfig struct {
	ServiceStructName          string
	ClientStructName           string
	InterfaceType              *types.Interface
	Implementation             types.Type
	ImplementationPackageName  string
	ImplementationName         string
	ImplementationRelativePath string
	ImplementationPackage      string
	ImplementationDirectory    string
}

type MethodDetails

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

Jump to

Keyboard shortcuts

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