# 6.5 编译日志

在[Schedule.StaticInit()](/6.-golang-bian-yi-qi-chu-shi-hua-ren-wu/6.4-fu-zhi-yu-ju.md#chu-shi-hua-shi-jian)方法中我们可以看到`base.Flag.Percent`用来控制是否 dump 动态初始化语句，该 Flag 对应的编译参数是`-%`. 将如下代码保存至文件`main.go` 中：

```go
package main

import "unsafe"

// 静态初始化语句
var version = 1.2
var versionAlias = version
var names = []string{"Goalng"}
var nameBytes []byte = []byte("Golang")
var nameSize = unsafe.Sizeof("Golang!") // 此处 unsafe.Sizeof 的代码在编译时执行

// 动态初始化语句
var nextVersion = version + 1
var firstName = names[0]
```

通过命令编译文件`go tool compile -G=3 -%=1 main.go`会得到如下结果：

> ```
> nonstatic [0xc000111d60]
> .   AS tc(1) # main.go:13
> .   .   NAME-main.nextVersion tc(1) Class:PEXTERN Offset:0 float64 # main.go:13
> .   .   ADD tc(1) float64 # main.go:13 float64
> .   .   .   NAME-main.version tc(1) Class:PEXTERN Offset:0 float64 # main.go:7
> .   .   .   LITERAL-1 tc(1) float64 # main.go:13
> nonstatic [0xc000111e50]
> .   AS tc(1) # main.go:14
> .   .   NAME-main.firstName tc(1) Class:PEXTERN Offset:0 string # main.go:14
> .   .   INDEX tc(1) string # main.go:14 string
> .   .   .   NAME-main.names tc(1) Class:PEXTERN Offset:0 SLICE-[]string # main.go:9
> .   .   .   LITERAL-0 tc(1) int # main.go:14
> ```

可以看出`nextVersion`与`firstName`两个赋值语句的初始化需要在运行时进行。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gocompiler.shizhz.me/6.-golang-bian-yi-qi-chu-shi-hua-ren-wu/6.5-bian-yi-ri-zhi.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
