pkg

package
v0.0.0-...-5ab778b Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2023 License: Unlicense Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ImportKeyWord is the keyword "import"
	ImportKeyWord string = "import"
	// VarKeyWord is the keyword "var"
	VarKeyWord string = "var"
	// ConstKeyWord is the keyword "const"
	ConstKeyWord string = "const"
	// TypeKeyWord is the keyword "type"
	TypeKeyWord string = "type"
	// EmptyInterface is the empty interface keyword
	EmptyInterface = "interface{}"
)

Variables

This section is empty.

Functions

func TypeParts

func TypeParts(selector string) (string, string)

TypeParts returns the package and the name of a flattened type

Types

type Array

type Array struct {
	Type      Variable
	StrValues []string
}

Array is a go array

type Field

type Field struct {
	Name string
	Type string
	Tag  string
}

Field is a struct field

type File

type File struct {
	Pkg         *Pkg
	Name        string
	FSet        *token.FileSet
	File        *ast.File
	Structs     []Struct
	Imports     []Import
	GlobalVars  []Variable
	GlobalConst []Variable
	Functions   []Function
	// contains filtered or unexported fields
}

File is a go file

func (*File) FindFunc

func (file *File) FindFunc(fun *Function) error

FindFunc find a function in a file

func (*File) FindStruct

func (file *File) FindStruct(str *Struct) error

FindStruct find a struct in a file

func (*File) SearchForStructRoutes

func (file *File) SearchForStructRoutes(structRoute criteria.StructRoute) []Route

SearchForStructRoutes searches for struct routes inside a file

type Function

type Function struct {
	File     *File
	Name     string
	MemberOf string
	Args     []Variable
	Return   []string
	// contains filtered or unexported fields
}

Function is a function in a package

func (Function) FindArgTypeCallExpression

func (f Function) FindArgTypeCallExpression(callCriteria criteria.CallCriteria) (string, error)

FindArgTypeCallExpression given a call expression it finds the type of the argument

func (Function) FindErrorResponseCallExpressionAfter

func (f Function) FindErrorResponseCallExpressionAfter(callCriteria criteria.CallCriteria, pos *token.Pos, modelResponse *ModelResponse) error

FindErrorResponseCallExpressionAfter given a call expression it finds the type of the argument past a position

func (Function) FindResponseCallExpressionAfter

func (f Function) FindResponseCallExpressionAfter(callCriteria criteria.CallCriteria, pos *token.Pos, modelResponse *ModelResponse) error

FindResponseCallExpressionAfter given a call expression it finds the type of the argument past a position

func (Function) ListVariablesUntil

func (f Function) ListVariablesUntil(until token.Pos) []Variable

ListVariablesUntil returns a list of all the variables until a position

type Import

type Import struct {
	Name string
	Pkg  string
}

Import represent the imports of a go file

type ModelResponse

type ModelResponse struct {
	Type string
	Pos  token.Pos
	Code string
}

ModelResponse is a response model

type Pkg

type Pkg struct {
	Project   *Project
	Name      string
	Path      string
	Files     []File
	Logger    *log.Logger
	BlackList []*regexp.Regexp
}

Pkg is a package

func AnalizeProject

func AnalizeProject(path string, logger *log.Logger) ([]*Pkg, error)

AnalizeProject reads a project and returns a list of packages

func AnalizeProjectWithBlacklist

func AnalizeProjectWithBlacklist(path string, logger *log.Logger, blacklist []*regexp.Regexp) ([]*Pkg, error)

AnalizeProjectWithBlacklist reads a project excluding some files and returns a list of packages

func NewPkgWithoutTest

func NewPkgWithoutTest(name, path string, logger *log.Logger) *Pkg

NewPkgWithoutTest creates a new package with the default blacklist

func (*Pkg) Analyze

func (p *Pkg) Analyze() error

Analyze a package

func (*Pkg) FindFunc

func (p *Pkg) FindFunc(fun *Function) error

FindFunc attempts to find a function in every file of the package

func (*Pkg) FindStruct

func (p *Pkg) FindStruct(str *Struct) error

FindStruct find a struct in a package

func (*Pkg) SearchForStructRoutes

func (p *Pkg) SearchForStructRoutes(structRoute criteria.StructRoute) []Route

SearchForStructRoutes searches for struct routes

type Project

type Project struct {
	RootPath  string
	Blacklist []*regexp.Regexp
	Pkgs      []*Pkg
}

Project is a golang project

func (*Project) FindFunc

func (p *Project) FindFunc(fun *Function) error

FindFunc attempts to find a function in every file of the package

func (*Project) FindStruct

func (p *Project) FindStruct(str *Struct) error

FindStruct find a struct in a package

func (*Project) SearchForStructRoutes

func (p *Project) SearchForStructRoutes(structRoute criteria.StructRoute) []Route

SearchForStructRoutes searches for struct routes

type Route

type Route struct {
	Pkg                        string
	File                       string
	Path                       string
	HTTPMethod                 string
	HandlerType                string
	NamedPathVarExtractor      *regexp.Regexp
	ChildRoutes                []*Route
	Middlewares                []string
	RequestModel               Struct
	ServiceResponses           []ServiceResponse
	Struct                     map[string]string
	MatchedParameters          map[string]bool
	MatchedSecurityDefinitions map[string]bool
}

Route is web route found in the folder

type ServiceResponse

type ServiceResponse struct {
	Code           string
	ModelExtractor criteria.ModelExtractor
	Model          Struct
}

ServiceResponse is the response from a service

type Struct

type Struct struct {
	File         *File
	PkgName      string
	Name         string
	Fields       []Field
	CallCriteria criteria.CallCriteria
	Schema       *openapi3.Schema
}

Struct is a struct

func (*Struct) ToSwaggerSchema

func (s *Struct) ToSwaggerSchema() error

ToSwaggerSchema populates a given swagger schema with the data from the struct

type Variable

type Variable struct {
	Name        string
	GoType      string
	StrValue    string
	MapValue    map[string]*Variable
	ArrayValue  *Array
	SubVariable *Variable
}

Variable is a variable

func (*Variable) AssignValue

func (v *Variable) AssignValue(n ast.Node)

AssignValue given the ast node assigns the variable a value

func (*Variable) Extract

func (v *Variable) Extract(n ast.Node)

Extract its structure from an ast node

Jump to

Keyboard shortcuts

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