astgo

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2024 License: MIT Imports: 11 Imported by: 0

README

Astgo

Go doc

暂无介绍...

目录导航

列出了该 package 下所有的函数及类型定义,可通过目录导航进行快捷跳转 ❤️

展开 / 折叠目录导航

包级函数定义

函数名称 描述
NewPackage 暂无描述...

类型定义

类型 名称 描述
STRUCT Comment 暂无描述...
STRUCT Field 暂无描述...
STRUCT File 暂无描述...
STRUCT Function 暂无描述...
STRUCT Package 暂无描述...
STRUCT Struct 暂无描述...
STRUCT Type 暂无描述...

详情信息

func NewPackage(dir string) (*Package, error)

查看 / 收起单元测试

func TestNewPackage(t *testing.T) {
	p, err := astgo.NewPackage(`/Users/kercylan/Coding.localized/Go/minotaur/server`)
	if err != nil {
		panic(err)
	}
	fmt.Println(string(super.MarshalIndentJSON(p, "", "  ")))
}


Comment STRUCT
type Comment struct {
	Comments []string
	Clear    []string
}

Field STRUCT
type Field struct {
	Anonymous bool
	Name      string
	Type      *Type
	Comments  *Comment
}

File STRUCT
type File struct {
	af        *ast.File
	owner     *Package
	FilePath  string
	Structs   []*Struct
	Functions []*Function
	Comment   *Comment
}

func (*File) Package() string

Function STRUCT
type Function struct {
	decl        *ast.FuncDecl
	Name        string
	Internal    bool
	Generic     []*Field
	Params      []*Field
	Results     []*Field
	Comments    *Comment
	Struct      *Field
	IsExample   bool
	IsTest      bool
	IsBenchmark bool
	Test        bool
}

func (*Function) Code() string

Package STRUCT
type Package struct {
	Dir       string
	Name      string
	Dirs      []string
	Files     []*File
	Functions map[string]*Function
}

func (*Package) StructFunc(name string) []*Function

func (*Package) PackageFunc() []*Function

func (*Package) Structs() []*Struct

func (*Package) FileComments() *Comment

func (*Package) GetUnitTest(f *Function) *Function

func (*Package) GetExampleTest(f *Function) *Function

func (*Package) GetBenchmarkTest(f *Function) *Function

Struct STRUCT
type Struct struct {
	Name      string
	Internal  bool
	Interface bool
	Comments  *Comment
	Generic   []*Field
	Fields    []*Field
	Type      *Type
	Test      bool
}

Type STRUCT
type Type struct {
	expr      ast.Expr
	Sign      string
	IsPointer bool
	Name      string
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comment

type Comment struct {
	Comments []string
	Clear    []string
}

type Field

type Field struct {
	Anonymous bool     // 匿名字段
	Name      string   // 字段名称
	Type      *Type    // 字段类型
	Comments  *Comment // 注释
}

type File

type File struct {
	FilePath  string      // 文件路径
	Structs   []*Struct   // 包含的结构体
	Functions []*Function // 包含的函数
	Comment   *Comment    // 文件注释
	// contains filtered or unexported fields
}

func (*File) Package

func (f *File) Package() string

type Function

type Function struct {
	Name        string   // 函数名
	Internal    bool     // 内部函数
	Generic     []*Field // 泛型定义
	Params      []*Field // 参数字段
	Results     []*Field // 返回值字段
	Comments    *Comment // 注释
	Struct      *Field   // 结构体函数对应的结构体字段
	IsExample   bool     // 是否为测试用例
	IsTest      bool     // 是否为单元测试
	IsBenchmark bool     // 是否为基准测试
	Test        bool     // 是否为测试函数
	// contains filtered or unexported fields
}

func (*Function) Code

func (f *Function) Code() string

type Package

type Package struct {
	Dir       string
	Name      string
	Dirs      []string
	Files     []*File
	Functions map[string]*Function
}

func NewPackage

func NewPackage(dir string) (*Package, error)

func (*Package) FileComments

func (p *Package) FileComments() *Comment

func (*Package) GetBenchmarkTest

func (p *Package) GetBenchmarkTest(f *Function) *Function

func (*Package) GetExampleTest

func (p *Package) GetExampleTest(f *Function) *Function

func (*Package) GetUnitTest

func (p *Package) GetUnitTest(f *Function) *Function

func (*Package) PackageFunc

func (p *Package) PackageFunc() []*Function

func (*Package) StructFunc

func (p *Package) StructFunc(name string) []*Function

func (*Package) Structs

func (p *Package) Structs() []*Struct

type Struct

type Struct struct {
	Name      string   // 结构体名称
	Internal  bool     // 内部结构体
	Interface bool     // 接口定义
	Comments  *Comment // 注释
	Generic   []*Field // 泛型类型
	Fields    []*Field // 结构体字段
	Type      *Type    // 和结构体字段二选一,处理类似 type a string 的情况
	Test      bool     // 是否是测试结构体
}

type Type

type Type struct {
	Sign      string // 类型签名
	IsPointer bool   // 指针类型
	Name      string // 类型名称
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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