GoPLS Viewer

Home|gopls/cmd/stringer/testdata/number.go
1// Copyright 2014 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5// Enumeration with an offset.
6// Also includes a duplicate.
7
8package main
9
10import "fmt"
11
12type Number int
13
14const (
15    _ Number = iota
16    One
17    Two
18    Three
19    AnotherOne = One // Duplicate; note that AnotherOne doesn't appear below.
20)
21
22func main() {
23    ck(One"One")
24    ck(Two"Two")
25    ck(Three"Three")
26    ck(AnotherOne"One")
27    ck(127"Number(127)")
28}
29
30func ck(num Numberstr string) {
31    if fmt.Sprint(num) != str {
32        panic("number.go: " + str)
33    }
34}
35
MembersX
Number
AnotherOne
Members
X