github.com/graybobo/golang.org-package-offline-cache@v0.0.0-20200626051047-6608995c132f/x/talks/2014/taste/weekday.go (about)

     1  // +build OMIT
     2  
     3  package main
     4  
     5  import "fmt"
     6  
     7  // type START OMIT
     8  type Weekday int
     9  
    10  // type END OMIT
    11  
    12  const (
    13  	Mon Weekday = iota
    14  	Tue
    15  	Wed
    16  	Thu
    17  	Fri
    18  	Sat
    19  	Sun
    20  )
    21  
    22  var names = [...]string{"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}
    23  
    24  // String START OMIT
    25  func (d Weekday) String() string { // ...
    26  	// String END OMIT
    27  	return names[d]
    28  }
    29  
    30  // main START OMIT
    31  func main() {
    32  	fmt.Println(Mon.String())
    33  	fmt.Println()
    34  
    35  	for d := Mon; d <= Sun; d++ {
    36  		fmt.Println(d.String())
    37  	}
    38  }
    39  
    40  // main END OMIT