Delve代码分析笔记(1)——main.go

delve的项目主页:https://github.com/derekparker/delve
main.go的代码比较简单:

package main

import (
    "github.com/derekparker/delve/cmd/dlv/cmds"
    "github.com/derekparker/delve/version"
)

// Build is the git sha of this binaries build.
var Build string

func main() {
    version.DelveVersion.Build = Build
    cmds.New().Execute()
}

main函数就干了两件事:
(1)把Build的值赋给version.DelveVersion变量中的Build成员;
(2)cmds.New()返回一个cobra.Commandtree,然后调用Execute()函数执行相应的子命令,例如dlv version

 

发表评论

邮箱地址不会被公开。 必填项已用*标注

This site uses Akismet to reduce spam. Learn how your comment data is processed.