> For the complete documentation index, see [llms.txt](https://denglj.gitbook.io/essential-go/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://denglj.gitbook.io/essential-go/02-basic-types/constants.md).

# 常量

Go语言支持的常量包括：字符、字符串、布尔值、数字值。

**常量的声明**：

```go
const (
	i  int = 32       // int constant
	s      = "string" // string constant
	i2     = 33       // untyped number constant
)

var (
	// 非只读类型的值（如切片和映射）则不可以声明为常量
	// 我们只能把它们声明为变量
	b = []byte{3, 4} // 这不是一个常量
)
```
