1.关于plantuml
1.1 简介
Plant UML是一门类似于HTML的标记性语言,采用graphviz来渲染PlantUML,可集成在markdown。故而可以像维护代码一样维护 UML 图的历史版本,编写脚本就会自动生成UML图。用于会议讨论、流程设计、需求编写等环节。支持的工具集tools 不要太多!同时提供在线版工具:online-plantuml。www.plantuml.com/
PlantUML是一个快速创建UML图形的组件,其支持的图形有:
sequence diagram
use case diagram
class diagram
activity diagram
component diagram
state diagram
object diagram
wireframe graphical interface
1.2 go里面使用plantuml的方式
利用goplantuml(下载地址goplanuml),给他传入一个go包路径即可(在电脑里面的),然后他就会帮我们输出plantuml的文本 例如 .\goplantuml.exe G:\go\src\go\ast >1.txt 然后在线 www.plantuml.com/ 生成。
或者直接在www.dumels.com/ 进行查看
输入 github.com/golang/go/t… 生成即可查看,很方便
1.3 如何显示plantuml的表达式
vscode goland均提供了对应的插件,这里不多说。 另外可以直接在线 www.plantuml.com/ 生成。
ast的核心代码分析
//所有的节点类型,都要实现该接口,里面描述了该节点的起始结束的位置.
type Node interface {
Pos() token.Pos // position of first character belonging to the node
End() token.Pos // position of first character immediately after the node
}
//表达式类型,都要实现该接口.
type Expr interface {
Node
exprNode()
}
// 语句类型节点,都要实现该接口
type Stmt interface {
Node
stmtNode()
}
// 声明类型节点的接口
type Decl interface {
Node
declNode()
}