model

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Argument

type Argument struct {
	Name string
	Type QualifiedGoIdent
}

Argument is the identifier of a function argument, consisting of a name and type. The type is the qualified Go identifier. For example: `ctx context.Context` => Argument{Name: "ctx", Type: "context.Context"}.

func (Argument) String

func (arg Argument) String() string

String implements the fmt.Stringer interface for the Argument type. It simply combines the name and type with a space in between, for example: `ctx context.Context`.

type Method

type Method struct {
	*protogen.Method

	Receiver  Receiver
	Arguments []*Argument
	Return    []QualifiedGoIdent
}

A Method describes a method in a service. It extends the protogen's Method with the additional fields.

func NewMethod

func NewMethod(method *protogen.Method, receiver Receiver) *Method

NewMethod creates a new Method based on the provided protogen.Method.

func (*Method) AddArgument

func (m *Method) AddArgument(name, ident string) *Method

AddArgument adds an argument to the method.

func (*Method) AddReturn

func (m *Method) AddReturn(ret string) *Method

AddReturn adds a return type to the method.

func (*Method) SetReturn

func (m *Method) SetReturn(ret string) *Method

SetReturn sets the return type of the method.

func (*Method) String

func (m *Method) String() string

String implements the fmt.Stringer interface for the method type. It formattes a valid Go function signature, for example: `func (c *MyClient) MyMethod(ctx context.Context, in *MyRequest, opts ...grpc.CallOption) (*MyResponse, error)`.

type QualifiedGoIdent

type QualifiedGoIdent string

A QualifiedGoIdent is the qualified Go identifier of a type. For example: `context.Context` or `string`.

If the identifier is from a different Go package it will be qualified (package.name) and an import statement for the identifier's package is expected be included in the file. The identifier may also be a builtin or pointer type.

func (QualifiedGoIdent) IsPointer

func (ident QualifiedGoIdent) IsPointer() bool

IsPointer indicated if the go identifier is a pointer.

func (QualifiedGoIdent) IsVariadic

func (ident QualifiedGoIdent) IsVariadic() bool

IsVariadic indicates if the go identifier is variadic.

type Receiver

type Receiver struct {
	Name string
	Type string
}

Receiver is the identifier of a type, a method is defined on. It consists of the name and type of the receiver.

func (Receiver) String

func (rec Receiver) String() string

String implements the fmt.Stringer interface for the Receiver type. It simply combines the name and type with a space in between, for example: `c *MyClient`.

Jump to

Keyboard shortcuts

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