标签:style blog http io ar color sp on div
GOPATH\src\day\day.go
package day type Day uint const ( Sunday Day = iota Monday Tuseday Wednesday Thursday Friday Saturday ) func (day Day) String() string { switch day { case Sunday: return "Sunday" case Monday: return "Monday" case Tuseday: return "Tuesday" case Wednesday: return "Wednesday" case Friday: return "Friday" case Saturday: return "Saturday" default: return "Invalid" } }
main.go
package main import "fmt" import "day" func main() { var today day.Day today = day.Sunday tomorrow := day.Monday fmt.Println("today: ", today) fmt.Println("tomorrow: ", tomorrow) fmt.Printf("type of today: %T\n", today) fmt.Printf("type of tomorrow: %T\n", tomorrow) }
输出:
标签:style blog http io ar color sp on div
原文地址:http://www.cnblogs.com/CPyARM/p/4132987.html