8 Star 47 Fork 21

Lucky / go-hutool

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
04-constant.go 695 Bytes
一键复制 编辑 原始数据 按行查看 历史
Lucky 提交于 2020-02-19 16:20 . go 例子排版顺序
package main
/**
* Go by Example 中文版:常量
*/
import "fmt"
import "math"
//const 用于声明一个常量。
const s string = "constant"
func main() {
fmt.Println(s)
//const 语句可以出现在任何 var 语句可以出现 的地方
const n = 500000000
//常数表达式可以执行任意精度的运算
const d = 3e20 / n
fmt.Println(d)
//数值型常量没有确定的类型,直到被给定 ,比如一次显示的类型转化。
fmt.Println(int64(d))
//当上下文需要时,比如变量赋值或者函数调用, 一个数可以被给定一个类型。举个例子,这里的 math.Sin 函数需要一个 float64 的参数。
fmt.Println(math.Sin(n))
}
Go
1
https://gitee.com/huangbosbos/go-hutool.git
git@gitee.com:huangbosbos/go-hutool.git
huangbosbos
go-hutool
go-hutool
81f09a275c3b

搜索帮助

53164aa7 5694891 3bd8fe86 5694891