model

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package model contains models to pass data between analyzer and printer.

Index

Constants

This section is empty.

Variables

TypesKindToArgumentKind converts go.types basic kind to ArgumentKind.

Functions

This section is empty.

Types

type Argument

type Argument struct {
	PointerElement *Argument // Type has a star (pointer) to the type.

	NamedImport  string    // Path of the package with declarated named type.
	NamedName    string    // Name of the named type.
	NamedComment string    // Comments of the NamedObject.
	NamedObject  *Argument // Unwrapped argument of the named type.

	EnumBasicKind      ArgumentKind // Basic type of the Enum (named type).
	EnumElements       []*Argument  // List of values with comments of the enum.
	EnumElementName    string       // Name of the enum element.
	EnumElementValue   string       // Value of the enum element.
	EnumElementComment string       // Comment of the enum element.

	StructFields            []*Argument // List of the struct's fields.
	StructFieldName         string      // Name of the struct's field in json.
	StructFieldGoName       string      // Origin name of the struct's field.
	StructFieldComment      string      // Comment of the struct's field.
	StructFieldIsOptional   bool        // Filed of the struct has omitempty json tag.
	StructFieldIsDeprecated bool        // Filed of the struct has deprecated tag mark.

	SliceElement *Argument // Element of the slice.

	MapKey  *Argument // Key of the map.
	MapElem *Argument // Element of the map.

	BasicKind   ArgumentKind   // Basic type of the argument.
	BasicFormat ArgumentFormat // Additional format of the argument.

	IsEmptyInterface bool // Argument is an empty interface or any (1.18).
}

Argument of the method Parameter or Result.

func (*Argument) IsAny added in v0.0.2

func (a *Argument) IsAny() bool

IsAny returns true when argument is an empty interface or any.

any or any.

func (*Argument) IsBasic

func (a *Argument) IsBasic() bool

IsBasic returns true when the argument is a Basic type.

int, string, float64, ...

func (*Argument) IsEnum

func (a *Argument) IsEnum() bool

IsEnum returns true when the argument is a Named Object with Enum values.

func (*Argument) IsMap added in v0.0.2

func (a *Argument) IsMap() bool

IsMap returns true when argument is a Map.

map[string]*Type

func (*Argument) IsNamed

func (a *Argument) IsNamed() bool

IsNamed returns true when the argument is a Named Type.

type NamedType struct {

func (*Argument) IsPointer

func (a *Argument) IsPointer() bool

IsPointer returns true when the argument is a Pointer to type.

func(a *SomeType)

func (*Argument) IsSlice

func (a *Argument) IsSlice() bool

IsSlice returns true when the argument is a Slice.

[]*Named or []int

func (*Argument) IsStruct

func (a *Argument) IsStruct() bool

IsStruct returns true when the argument is a Struct.

struct{...}

type ArgumentFormat added in v0.0.2

type ArgumentFormat string

ArgumentFormat additional format of the argument.

const (
	// ArgumentFormatTime means time.Time type.
	ArgumentFormatTime ArgumentFormat = "date-time"
	// ArgumentFormatUUID means UUID string type.
	ArgumentFormatUUID ArgumentFormat = "uuid"
)

type ArgumentKind

type ArgumentKind int

ArgumentKind describes the kind of basic type.

const (
	ArgumentKindInvalid ArgumentKind = iota
	ArgumentKindBool
	ArgumentKindInt
	ArgumentKindInt8
	ArgumentKindInt16
	ArgumentKindInt32
	ArgumentKindInt64
	ArgumentKindUint
	ArgumentKindUint8
	ArgumentKindUint16
	ArgumentKindUint32
	ArgumentKindUint64
	ArgumentKindFloat32
	ArgumentKindFloat64
	ArgumentKindString
)

List of the kinds.

func GetArgumentKind

func GetArgumentKind(text string) ArgumentKind

GetArgumentKind returns ArgumentKind using on text name.

func (ArgumentKind) String

func (ak ArgumentKind) String() string

String converts int value to string name.

type Method

type Method struct {
	Name           string    // Name for code generator (snake case of the GoName or special name from comments).
	GoName         string    // Name of the methos in the go source file.
	Comments       string    // Comments of the method from go source file.
	SwaggerTags    []string  // List of the tags in swagger spec.
	Parameter      *Argument // Parameter of the method.
	Result         *Argument // Result of the method.
	IsDeprecated   bool      // Method marked as deprecated.
	IsNotification bool      // Method is a Notification.
}

Method method of the rpc service. Contains name of the method and arguments and result parameters.

type Service

type Service struct {
	Import    string    // Path of the package with interface.
	PkgName   string    // Name of the package with interface.
	Name      string    // Name for code generator (snake case of the GoName).
	GoName    string    // Name of the interface from go source file.
	Comments  string    // Comments of the service from go source file.
	Methods   []*Method // List of the methods.
	ErrorData *Argument // Model for "data" field in the JSON-RPC error.
}

Service is an interface in source code that describe rpc service. Interface contains methods and arguments with golang types.

Jump to

Keyboard shortcuts

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