github.com/cockroachdb/tools@v0.0.0-20230222021103-a6d27438930d/cmd/stringer/testdata/prime.go (about) 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 // Enough gaps to trigger a map implementation of the method. 6 // Also includes a duplicate to test that it doesn't cause problems 7 8 package main 9 10 import "fmt" 11 12 type Prime int 13 14 const ( 15 p2 Prime = 2 16 p3 Prime = 3 17 p5 Prime = 5 18 p7 Prime = 7 19 p77 Prime = 7 // Duplicate; note that p77 doesn't appear below. 20 p11 Prime = 11 21 p13 Prime = 13 22 p17 Prime = 17 23 p19 Prime = 19 24 p23 Prime = 23 25 p29 Prime = 29 26 p37 Prime = 31 27 p41 Prime = 41 28 p43 Prime = 43 29 ) 30 31 func main() { 32 ck(0, "Prime(0)") 33 ck(1, "Prime(1)") 34 ck(p2, "p2") 35 ck(p3, "p3") 36 ck(4, "Prime(4)") 37 ck(p5, "p5") 38 ck(p7, "p7") 39 ck(p77, "p7") 40 ck(p11, "p11") 41 ck(p13, "p13") 42 ck(p17, "p17") 43 ck(p19, "p19") 44 ck(p23, "p23") 45 ck(p29, "p29") 46 ck(p37, "p37") 47 ck(p41, "p41") 48 ck(p43, "p43") 49 ck(44, "Prime(44)") 50 } 51 52 func ck(prime Prime, str string) { 53 if fmt.Sprint(prime) != str { 54 panic("prime.go: " + str) 55 } 56 }