GoPLS Viewer

Home|gopls/cmd/stringer/testdata/conv.go
1// Copyright 2018 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// Check that constants defined as a conversion are accepted.
6
7package main
8
9import "fmt"
10
11type Other int // Imagine this is in another package.
12
13const (
14    alpha Other = iota
15    beta
16    gamma
17    delta
18)
19
20type Conv int
21
22const (
23    Alpha = Conv(alpha)
24    Beta  = Conv(beta)
25    Gamma = Conv(gamma)
26    Delta = Conv(delta)
27)
28
29func main() {
30    ck(Alpha"Alpha")
31    ck(Beta"Beta")
32    ck(Gamma"Gamma")
33    ck(Delta"Delta")
34    ck(42"Conv(42)")
35}
36
37func ck(c Convstr string) {
38    if fmt.Sprint(c) != str {
39        panic("conv.go: " + str)
40    }
41}
42
MembersX
alpha
Conv
ck.c
Other
Members
X