# 4.4.2 数据结构 - Package

package 的数据结构定义在文件`$GCROOT/compile/internal/types2/package.go`中：

```go
type Package struct {
	path     string     // 包的引用路径，例如 import "fmt" 中的 "fmt"
	name     string     // 包名，即代码中 package xxx 声明的内容
	scope    *Scope     // 包作用域，该包的 public 符号对象都在该作用域内
	complete bool       // 如果该包的 scope 内包含了所有的 public 符号对象，则为 true, 否则为 false
	imports  []*Package // 该包的依赖
	fake     bool
	cgo      bool
}
```

包通常以对象文件（.o 或者 .a 文件）的形式存在于文件系统中，而`Package`则对应一个对象文件在编译器中的内存结构。在编译阶段，包加载器负责完成包的加载与解析，包内符号对象都在`scope`属性中，下文[包加载器](/golang-bian-yi-qi-lei-xing-jian-cha/lei-xing-jian-cha-luo-ji.md)一节会对加载逻辑做详细介绍。


---

# 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/golang-bian-yi-qi-lei-xing-jian-cha/4.4.2-shu-ju-jie-gou-package.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.
