Version: v1.1.1 Latest Latest

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

Go to latest
Published: Sep 13, 2019 License: MIT Imports: 13 Imported by: 10




View Source
const (
	GenerateFileSuffix = "_zenrpc.go"


This section is empty.


This section is empty.


type Arg

type Arg struct {
	Name            string
	Type            string
	CapitalName     string
	JsonName        string
	HasStar         bool
	HasDefaultValue bool
	Description     string // from magic comment
	SMDType         SMDType

type DefaultValue

type DefaultValue struct {
	Name        string
	CapitalName string
	Type        string // without star
	Comment     string // original comment
	Value       string

type Method

type Method struct {
	FuncDecl      *ast.FuncType
	Name          string
	LowerCaseName string
	HasContext    bool
	Args          []Arg
	DefaultValues map[string]DefaultValue
	Returns       []Return
	SMDReturn     *SMDReturn // return for generate smd schema; pointer for nil check
	Description   string

	Errors []SMDError // errors for documentation in SMD

type PackageInfo

type PackageInfo struct {
	Dir string

	PackageName string
	Services    []*Service

	Scopes  map[string][]*ast.Scope // key - import name, value - array of scopes from each package file
	Structs map[string]*Struct
	Imports []*ast.ImportSpec

	StructsNamespacesFromArgs map[string]struct{} // set of structs names from arguments for printing imports
	ImportsForGeneration      []*ast.ImportSpec

PackageInfo represents struct info for XXX_zenrpc.go file generation

func NewPackageInfo

func NewPackageInfo() *PackageInfo

func (*PackageInfo) Parse

func (pi *PackageInfo) Parse(filename string) error

ParseFiles parse all files associated with package from original file

func (PackageInfo) String

func (pi PackageInfo) String() string

type Property

type Property struct {
	Name        string
	Description string
	SMDType     SMDType

type Return

type Return struct {
	Name string
	Type string

type SMDError

type SMDError struct {
	Code        int
	Description string

type SMDReturn

type SMDReturn struct {
	Name        string
	HasStar     bool
	Description string
	SMDType     SMDType

type SMDType

type SMDType struct {
	Type      string
	ItemsType string // for array
	Ref       string // for object and also if array item is object

SMDType is a type representation for SMD generation

type Service

type Service struct {
	GenDecl     *ast.GenDecl
	Name        string
	Methods     []*Method
	Description string

func (Service) HasErrorVariable

func (s Service) HasErrorVariable() bool

HasErrorVariable define adding err variable to generated Invoke function

type Struct

type Struct struct {
	Name       string // key in map, Ref in arguments and returns
	Namespace  string
	Type       string
	StructType *ast.StructType
	Properties []Property // array because order is important

func Definitions

func Definitions(smdType SMDType, structs map[string]*Struct) []*Struct

Definitions returns list of structs used inside smdType

Jump to

Keyboard shortcuts

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