Go基础_1_1 const常量
Tutorial: Go初级
Category: Go
Published: 2026-04-07 13:58:26
Views: 21
Likes: 0
Comments: 0
package main
import "fmt"
func main() {
fmt.Println(100)
fmt.Println("hello")
const PATH string = "http:www.baidu.com"
const PI = 3.14
fmt.Println(PATH)
const C1, C2, C3 = 100, 3.14, "haha"
const (
MALE = 0
FEMALE = 1
UNKNOW = 3
)
const (
a int = 100
b
c string = "ruby"
d
e
)
fmt.Printf("%T,%d\n", a, a)
fmt.Printf("%T,%d\n", b, b)
fmt.Printf("%T,%s\n", c, c)
fmt.Printf("%T,%s\n", d, d)
fmt.Printf("%T,%s\n", e, e)
const (
SPRING = 0
SUMMER = 1
AUTUMN = 2
WINTER = 3
)
}