time/time.go
package main

import (
    "fmt"
    "time"
)

// A Weekday specifies a day of the week (Sunday = 0, ...).
type Weekday int

const (
    Sunday    Weekday = iota
    Monday
    Tuesday
    Wednesday
    Thursday
    Friday
    Saturday
)

var days = [...]string{
    "Sunday",
    "Monday",
    "Tuesday",
    "Wednesday",
    "Thursday",
    "Friday",
    "Saturday",
}

// String returns the English name of the day ("Sunday", "Monday", ...).
func (d Weekday) String() string { return days[d] }

func main() {
    fmt.Println(Friday.String())
    fmt.Println(Monday.String())
    fmt.Println(Tuesday.String())

    fmt.Println(time.Friday.String())
}

1.iota关键字只能用在const常量中,还可以使用。

2.可以利用基本类型(比如int)来定义一个自己的自定义类型,然后添加自己想要的方法。同时该类型具有基本类型的属性和方法。