0076-Go-常量
Go 常量
2023-09-27 14:23:45 时间
环境
- Time 2022-08-23
- Go 1.19
前言
说明
参考:https://gobyexample.com/constants
目标
使用 Go 语言的常量。
示例
package main
import (
"fmt"
"math"
)
const s string = "constant"
func main() {
fmt.Println(s)
const n = 500000000
const d = 3e20 / n
fmt.Println(d)
fmt.Println(int64(d))
// 数值型常量的类型可以自动转换
fmt.Println(math.Sin(n))
}
总结
使用 Go 语言的常量。