关于golang:Golang编译器源码分析2

4次阅读

共计 375 个字符,预计需要花费 1 分钟才能阅读完成。

下来咱们来通过 Goland IDE 来 debug 下 golang 编译器

一、golang 程序源码如下
package main

import "fmt"

type st struct {
    name string
    age  int
}
type St st
var (
    avg int32  = 123
    tag string = "aaa"
    //ttt int64
)
const (
    A = 111
    B = 222
)
func Echo(t string, f interface{}) {fmt.Printf(t, f)
}
func init() {}
func main() {a := [...]int{1, 2, 3}
    Echo("a:%+v", a)
}
二、端点设置

断点设置 go/src/cmd/compile/internal/gc/noder.go:246 行

运行至端点后鼠标浮于 xtop 变量之上,点击 + 号浮框展现变量内容:

开展 xtop 变量察看语法树数组构造如下:

正文完
 0