# README
astp
A golang ast syntax tree parser
parse your source code, and describe them with json or yaml
Features
- 解析一个项目代码,生成可序列化内容
- 内置处理枚举写法
- 内置处理泛型和对象继承写法
Usage
Common Use
package main
import (
"flag"
"fmt"
"github.com/linxlib/astp"
)
var (
outFile string
)
func init() {
flag.StringVar(&outFile, "o", "default", "-o gen.json")
}
func main() {
flag.Parse()
p := astp.NewParser()
p.Parse()
if outFile == "" {
outFile = "gen.json"
}
err := p.WriteOut(outFile)
if err != nil {
fmt.Println(err)
}
fmt.Println("complete!")
}
Load
package main
import (
"github.com/linxlib/astp"
)
func main() {
parser := astp.NewParser()
parser.Load("gen.json")
// 循环
parser.VisitStruct(func(element *astp.Element) bool {
return true
}, func(e *astp.Element) {
})
}
Use it with go generate
//go:generate go run github.com/linxlib/astp/astpg -o gen.json
Examples
check fw and fw_example for details
# Functions
CheckPackage 返回某个包是何种类型的包.
No description provided by the author
No description provided by the author
No description provided by the author
ParseIt 返回一个类型是否需要进行解析(第三方包 系统内置包).
# Constants
内建类型.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
当前模块的其他包.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
在相同包下, 待后续解析.
第三方包.
# Type aliases
No description provided by the author
No description provided by the author
No description provided by the author