当前位置:网站首页>My first experience of go+ language -- a collection of notes on learning go+ design architecture
My first experience of go+ language -- a collection of notes on learning go+ design architecture
2022-06-25 12:47:00 【Coconut brine Engineer】
Go+ Installation tutorial for
There is a share in front , Through train :https://bbs.csdn.net/topics/603567061
Go+ Overall architecture

The starting point :Go+ Source code
End : An executable file ( Software ) or A bag (package)
The process : Enter the source code , In the middle token flow , experience AST Abstract syntax tree ,Dom Writer It's like a container , You can fill it with things , Finally can form Go The abstract syntax tree of , adopt go The command-line tool converts to an executable file .
The build process :
1)gop/token
- token The concept of compilation principle is similar to the words in natural language
- The source code is a stream of bytes :[]byte
- Need to pass through lex Process becomes token flow :[]token
2)gop/scanner
- scanner In compiling principle lex The process ( Lexical analysis )
- It usually does not require us to actively invoke , It's about using parser call
3)gop/parser
- In compiling principle parser The process ( Syntax analysis ), Responsible for token The circulation is DOM( namely []token => AST)
parser How to use :Go+ And Go It's the same prototype
func(os.FileInfo)bool,mode Mode)(pkgs map[string]*ast.Package,first error) ```
- fset: It is mainly used to record file offset offset And row number line:col The relationship between
- path: The path where the source code is located
- filter: Filter the file path
- mode: Some control parser Process of flags, It can be transmitted 0
- pkgs: Got AST
- first: stay parser When something goes wrong , The first error that occurred
4)gop/ast
- AST The full name of is abstract syntax tree , It's language DOM
- DOM It is a classic pattern in text processing (XML/json And other general documents have their own DOM, This and language have their own AST Essentially the same )
5)gop/cl
- compile ( Syntax analysis ): Responsible for the Go+AST Convert to right gox DOM Writer Call to
- It means cl The implementation is from Go+AST DOM To another DOM Transformation of
cl How to use
*Config)(p *gox.Package,err error) ```
- pkgPath: The target to compile Go+pkg Of import route
- pkg: The target to compile Go+pkg Of AST
- conf: Configuration for compilation
- p: Generated gox DOM Writer, Other interfaces have been called to complete the format conversion
- err: If an error occurs during compilation , All compilation errors are returned
6)gox
- It's a Go Linguistic DOM Writer Components , Used to generate Go AST
- therefore cl+gox It's done Go+AST To Go AST Transformation
gox How to use
Part to cl Irrigation data , To realize format conversion , One part is used to generate Go AST/Source Of
7)go
- With Go AST/Source after , You can use it go tools To compile
gop run . The core processes (hello world Implementation process )
fset:= token.NewFileSet()
pkgGops,err:= parser.ParseDir(fset,".",nil,0)
pfgFox,err:= cl.NewPackage("main",pkgGopx["mian"].nil)
err = gox.WriteFile("gop_autogen.go",pkgGox,false)
err = exec.Command("go","run","gop_autogen.go").Run()
边栏推荐
- Ubuntu uninstalling PHP
- Mind mapping video
- Micro engine remote attachment 7 Niu cloud upload
- Swagger document generated by node project API in vscode
- (7) Pyqt5 tutorial -- > > window properties and basic controls (continuous update)
- 阿里稳定性之故障应急处理流程
- Draw the satellite sky map according to the azimuth and elevation of the satellite (QT Implementation)
- 顺序表的折半查找法
- How to implement a high-performance load balancing architecture?
- 3+1保障:高可用系统稳定性是如何炼成的?
猜你喜欢

高性能负载均衡架构如何实现?

(2) Pyqt5 tutorial -- > using qtdesigner to separate interface code

GPS receiver design (1)

美创入选“2022 CCIA中国网络安全竞争力50强”榜单

Service charge and time setting code sharing involved in crmeb withdrawal process

架构师需要具备的能力

2021-09-28

地理空间搜索:kd树的实现原理

MySQL common interview questions
![按权重随机选择[前缀和+二分+随机target]](/img/84/7f930f55f8006a4bf6e23ef05676ac.png)
按权重随机选择[前缀和+二分+随机target]
随机推荐
Development with courtesy -- share the source code of the secondary development of the app system of the imitation shopping mall
Wechat forbids sharing
为何数据库也云原生了?
Error while sending STMT_ PREPARE packet. PID=29294
Zhangxiaobai's road of penetration (VI) -- the idea and process of SQL injection and the concat series functions and information of SQL_ Schema database explanation
Differences between JS and JQ operation objects
Zhangxiaobai's road to penetration (7) -sql injection detailed operation steps -union joint query injection
Zhangxiaobai's way of penetration (V) -- detailed explanation of upload vulnerability and parsing vulnerability
Laravel echart statistical chart line chart
Zhangxiaobai's road of penetration (IV) -- detailed explanation of XSS cross site script vulnerabilities
Concise H5 error page
First acquaintance with CANopen
Penetration tool environment - installing sqli labs in centos7 environment
Spicy food advertising e-commerce system development function and spicy food advertising e-commerce app system development source code sharing
Draw the satellite sky map according to the azimuth and elevation of the satellite (QT Implementation)
el-select clear 清空内容时触发事件
线上服务应急攻关方法论
Geospatial search: implementation principle of KD tree
Maximum number [abstract rules for abstract sorting]
阿里稳定性之故障应急处理流程