Source file
test/fixedbugs/issue24799.go
1
2
3
4
5
6
7
8
9
10 package main
11
12 import (
13 "fmt"
14 )
15
16 type Level string
17
18
19
20
21
22
23
24
25
26
27
28 const (
29 LevelBad Level = "badvals"
30 LevelNone Level = "No"
31 LevelMetadata Level = "Metadata"
32 LevelRequest Level = "Request"
33 LevelRequestResponse Level = "RequestResponse"
34 )
35
36 func ordLevel(l Level) int {
37 switch l {
38 case LevelMetadata:
39 return 1
40 case LevelRequest:
41 return 2
42 case LevelRequestResponse:
43 return 3
44 default:
45 return 0
46 }
47 }
48
49
50 func test(l Level) {
51 if ordLevel(l) < ordLevel(LevelMetadata) {
52 fmt.Printf("OK\n")
53 }
54 }
55
56 func main() {
57 test(LevelMetadata)
58 }
59
View as plain text