internal

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(_ context.Context, source, dest, version string) ([]byte, error)

Types

type File

type File struct {
	// Version represents the version of nrdeco used to generate this file.
	Version             string
	PackageName         string
	OriginalPackageName string
	Imports             map[string]Package
	Interfaces          []Interface
	// DifferInDest indicates if the file to be generated in a different destination than the original file.
	DifferInDest bool
}

File represents a Go source file

func (*File) InterfaceNameWithPackage

func (f *File) InterfaceNameWithPackage(name string) string

InterfaceNameWithPackage returns the interface name with the package identifier if the file is generated in a different destination than the original file.

func (*File) StringOfImports

func (f *File) StringOfImports() string

StringOfImports returns a string representation of the imports in the file, sorted by package path

type Imports

type Imports []Package

type Interface

type Interface struct {
	Name    string
	Methods []Method
}

Interface represents a type

type Method

type Method struct {
	Name    string
	Params  Params
	Returns Returns
}

Method represents a method

func (*Method) Signature

func (m *Method) Signature() string

Signature returns the method signature in the format "MethodName(ctx context.Context, arg1 Arg1Type, arg2 Arg2Type) (_ Return0Type, _ Return1Type)".

type Package

type Package struct {
	Path string
}

Package represents a Go package.

type Params

type Params []Value

Params represents the method parameters

func (*Params) BeGenerated

func (p *Params) BeGenerated() bool

BeGenerated checks if the Params slice contains follow parameters that should be generated.

- context.Context

func (*Params) Call

func (p *Params) Call() string

Call returns the method parameters in the format "ctx, arg1, arg2".

func (*Params) Signature

func (p *Params) Signature() string

Signature returns the method parameters in the format "ctx context.Context, arg1 Arg1Type, arg2 Arg2Type".

type Returns

type Returns []Value

Returns represents the method return values

type Value

type Value struct {
	Package *Package
	Type    string
	Key     string
	Element *Value
	Params  Params
	Returns Returns
}

Value represents a parameter or return value.

func (*Value) IsContext

func (v *Value) IsContext() bool

IsContext return true if the value is a context.Context type, otherwise false.

func (*Value) StringOfType

func (v *Value) StringOfType() string

StringOfType returns the string representation of the value's type

type Visitor

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

Visitor visits each *astutil.Cursor to find interfaces and their methods

func (*Visitor) Visit

func (v *Visitor) Visit(c *astutil.Cursor) bool

Jump to

Keyboard shortcuts

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