gosrc

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DebugLog = log.New(os.Stderr, "D ", 0)

DebugLog is log destination for debug messages

View Source
var WarnLog = log.New(os.Stderr, "W ", log.LstdFlags)

WarnLog is log destination for warning messages

Functions

This section is empty.

Types

type Field

type Field struct {
	Name string
	Type string
	Tag  *Tag
}

Field represents a variable.

type Func

type Func struct {
	Name    string
	Params  []*Var
	Results []*Var
}

Func represents a function.

type Import

type Import struct {
	Name string
	Path string
}

Import represents an import.

type Package

type Package struct {
	Name string

	Imports []*Import

	Values []*Value
	Funcs  map[string]*Func
	Types  map[string]*Type
}

Package represents a go pacakge.

func Read

func Read(path string) (*Package, error)

Read reads a file or directory as a Package.

func ReadDir

func ReadDir(path string) (*Package, error)

ReadDir reads all files in a directory as a Package.

func ReadFile

func ReadFile(name string) (*Package, error)

ReadFile reads a file as a Package.

type Parser

type Parser struct {
	Package *Package
}

Parser is a parser for go source files.

type Tag

type Tag struct {
	Raw    string
	Values map[string]*TagValue
}

Tag represents a tag for field

type TagValue

type TagValue struct {
	Raw    string
	Values []string
}

TagValue represents content of a tag.

type Type

type Type struct {
	Name     string
	Embedded map[string]struct{}
	Methods  map[string]*Func
	Fields   map[string]*Field
	IsStruct bool
	// contains filtered or unexported fields
}

Type represents a function.

func (*Type) FieldsByTag

func (t *Type) FieldsByTag(tagQuery string) []*Field

FieldsByTag collects fields which match with query. The query's format is "{tagName}" or "{tagName}:{value}".

type Value

type Value struct {
	Name    string
	Type    string
	IsConst bool
}

Value represents a value or const

type Var

type Var struct {
	Name string
	Type string
}

Var represents a variable.

Jump to

Keyboard shortcuts

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