kmgGoSource

package
v0.0.0-...-05317bf Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2015 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetImportPathListFromFile

func GetImportPathListFromFile(filepath string) (importPathList []string, err error)

func MustGetGoTypeFromPkgPathAndTypeName

func MustGetGoTypeFromPkgPathAndTypeName(pkgPath string, typ string) types.Type

类型名称定义 github.com/bronze1man/kmg/kmgGoSource/testPackage.Demo

func MustGetGoTypesFromReflect

func MustGetGoTypesFromReflect(typ reflect.Type) types.Type

func MustGetMethodListFromGoTypes

func MustGetMethodListFromGoTypes(typ types.Type) (output []*types.Selection)

func MustNewGoTypesMainPackageFromImportPath

func MustNewGoTypesMainPackageFromImportPath(importPath string) *types.Package

返回这个导入路径的主Package的types.Package对象 TODO 解决测试package的问题

func MustNewMainAstPackageFromImportPath

func MustNewMainAstPackageFromImportPath(importPath string) (pkg *ast.Package, fset *token.FileSet)

func MustWriteGoTypes

func MustWriteGoTypes(thisPackagePath string, typi types.Type) (s string, addPkgPathList []string)

func UnquoteGolangDoubleQuote

func UnquoteGolangDoubleQuote(in string) (out string, err error)

反序列化 golang的双引号 "encoding/json" -> encoding/json

Types

type Func

type Func struct {
	Name       string
	InArgList  []FuncArgument
	OutArgList []FuncArgument
}

type FuncArgument

type FuncArgument struct {
	Name string
	Type Type
}

type Kind

type Kind string
const (
	Struct Kind = "Struct"
	Ptr    Kind = "Ptr"
)

type Method

type Method struct {
	Recv Type
	Func
}

type Package

type Package struct {
	// contains filtered or unexported fields
}

表示一个golang里面的package

func MustNewPackageFromImportPath

func MustNewPackageFromImportPath(importPath string) *Package

使用importPath获取一个Package, 仅支持导入一个目录作为一个package 只导入一个package里面的主package,xxx_test不导入. 注意: 需要源代码,需要使用kmg配置GOPATH

func (*Package) Name

func (pkg *Package) Name() string

package 的名字,填在 package 那个地方的名字 package kmgReflect

func (*Package) PkgPath

func (pkg *Package) PkgPath() string

填在import的那个路径的值

type Type

type Type interface {
	Kind() Kind
	Method() []Method
	//在这个pkgPath里面的表示方法
	WriteInPkgPath(currentPkgPath string) (str string, importPathList []string)
}

表示一种golang的类型

func MustNewTypeFromReflectType

func MustNewTypeFromReflectType(typ reflect.Type) Type

从反射的类型获取一个Type 主要: 需要运行时有源代码,需要使用kmg配置GOPATH

type TypePointer

type TypePointer struct {
	Elem Type
}

表示一个指针类型

func (TypePointer) Kind

func (p TypePointer) Kind() Kind

func (TypePointer) Method

func (p TypePointer) Method() []Method

func (TypePointer) WriteInPkgPath

func (p TypePointer) WriteInPkgPath(currentPkgPath string) (str string, importPathList []string)

type TypeStruct

type TypeStruct struct {
	// contains filtered or unexported fields
}

表示一个struct类型

func (TypeStruct) Kind

func (p TypeStruct) Kind() Kind

func (TypeStruct) Method

func (p TypeStruct) Method() []Method

func (TypeStruct) Package

func (p TypeStruct) Package() *Package

func (TypeStruct) WriteInPkgPath

func (p TypeStruct) WriteInPkgPath(currentPkgPath string) (str string, importPathList []string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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