code

package
v1.7.10 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArrayType

type ArrayType struct {
	ContainedType Type
}

ArrayType is a model of array

func (ArrayType) Code

func (t ArrayType) Code() string

Code returns token string in code format

type Coder

type Coder interface {
	Code() string
}

type ExternalType

type ExternalType struct {
	PackageAlias string
	Name         string
}

ExternalType is a type that is called to another package

func (ExternalType) Code

func (t ExternalType) Code() string

Code returns token string in code format

type File

type File struct {
	PackageName string
	Imports     []Import
	Structs     Structs
	Interfaces  Interfaces
	Methods     []Method
}

File is a container of all required components for code generation in the file

func ExportFile

func ExportFile(file *File) (*File, error)

func ExtractComponents

func ExtractComponents(f *ast.File) File

ExtractComponents converts ast file into code components model

func ExtractComponentsByPath

func ExtractComponentsByPath(componentPath string) (*File, error)

type Import

type Import struct {
	Name string
	Path string
}

Import is a model for package imports

type InterfaceType

type InterfaceType struct {
	Name    string
	Methods []Method
}

InterfaceType is a definition of the interface

func (InterfaceType) Code

func (intf InterfaceType) Code() string

Code returns token string in code format

type Interfaces

type Interfaces []InterfaceType

Interfaces is a group of Interface model

func (Interfaces) ByName

func (intfs Interfaces) ByName(name string) (InterfaceType, bool)

ByName return interface by name Another return value shows whether there is an interface with that name exists.

type MapType

type MapType struct {
	KeyType   Type
	ValueType Type
}

MapType is a model of map

func (MapType) Code

func (t MapType) Code() string

Code returns token string in code format

type Method

type Method struct {
	Receiver Type
	Name     string
	Comments []string
	Params   []Param
	Returns  []Type
}

Method is a definition of the method inside the interface

type Param

type Param struct {
	Name string
	Type Type
}

Param is a model of method parameter

type PointerType

type PointerType struct {
	ContainedType Type
}

PointerType is a model of pointer

func (PointerType) Code

func (t PointerType) Code() string

Code returns token string in code format

type SimpleType

type SimpleType string

SimpleType is a type that can be called directly

func (SimpleType) Code

func (t SimpleType) Code() string

Code returns token string in code format

func (SimpleType) IsBuildIn

func (t SimpleType) IsBuildIn() bool

type Struct

type Struct struct {
	PackageAlias string
	Name         string
	Fields       StructFields
}

Struct is a definition of the struct

func (Struct) ReferencedType

func (str Struct) ReferencedType() Type

ReferencedType returns a type variable of this struct

type StructField

type StructField struct {
	Name string
	Type Type
	Tags map[string][]string
}

StructField is a definition of the struct field

type StructFields

type StructFields []StructField

StructFields is a group of the StructField model

func (StructFields) ByName

func (fields StructFields) ByName(name string) (StructField, bool)

ByName return struct field with matching name

type Structs

type Structs []Struct

Structs is a group of Struct model

func (Structs) ByName

func (strs Structs) ByName(name string) (Struct, bool)

ByName return struct with matching name. Another return value shows whether there is a struct with that name exists.

type Type

type Type interface {
	Coder
}

Type is an interface for value types

Jump to

Keyboard shortcuts

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