GoPLS Viewer

Home|gopls/go/analysis/passes/stdmethods/testdata/src/a/a.go
1// Copyright 2010 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
5package a
6
7import (
8    "encoding/xml"
9    "fmt"
10    "io"
11)
12
13type T int
14
15func (TScan(x fmt.ScanStatec byte) {} // want `should have signature Scan\(fmt\.ScanState, rune\) error`
16
17func (TFormat(fmt.Statebyte) {} // want `should have signature Format\(fmt.State, rune\)`
18
19type U int
20
21func (UFormat(byte) {} // no error: first parameter must be fmt.State to trigger check
22
23func (UGobDecode() {} // want `should have signature GobDecode\(\[\]byte\) error`
24
25// Test rendering of type names such as xml.Encoder in diagnostic.
26func (UMarshalXML(*xml.Encoder) {} // want `method MarshalXML\(\*xml.Encoder\) should...`
27
28func (UUnmarshalXML(*xml.Decoderxml.StartElementerror { // no error: signature matches xml.Unmarshaler
29    return nil
30}
31
32func (UWriteTo(w io.Writer) {} // want `method WriteTo\(w io.Writer\) should have signature WriteTo\(io.Writer\) \(int64, error\)`
33
34func (TWriteTo(w io.Writermoreargs int) {} // ok - clearly not io.WriterTo
35
36type I interface {
37    ReadByte() byte // want `should have signature ReadByte\(\) \(byte, error\)`
38}
39
40type V int // V does not implement error.
41
42func (VAs() T       { return 0 }     // ok - V is not an error
43func (VIs() bool    { return false } // ok - V is not an error
44func (VUnwrap() int { return 0 }     // ok - V is not an error
45
46type E int
47
48func (EError() string { return "" } // E implements error.
49
50func (EAs()     {} // want `method As\(\) should have signature As\((any|interface\{\})\) bool`
51func (EIs()     {} // want `method Is\(\) should have signature Is\(error\) bool`
52func (EUnwrap() {} // want `method Unwrap\(\) should have signature Unwrap\(\) error or Unwrap\(\) \[\]error`
53
54type F int
55
56func (FError() string { return "" } // Both F and *F implement error.
57
58func (*FAs()     {} // want `method As\(\) should have signature As\((any|interface\{\})\) bool`
59func (*FIs()     {} // want `method Is\(\) should have signature Is\(error\) bool`
60func (*FUnwrap() {} // want `method Unwrap\(\) should have signature Unwrap\(\) error or Unwrap\(\) \[\]error`
61
62type G int
63
64func (GAs(interface{}) bool // ok
65
66type W int
67
68func (WError() string { return "" }
69func (WUnwrap() error { return nil } // ok
70
71type M int
72
73func (MError() string   { return "" }
74func (MUnwrap() []error { return nil } // ok
75
MembersX
V.As
E
W
T.Scan.x
U.UnmarshalXML
T.WriteTo.w
V
U.MarshalXML
F.As
F.Unwrap
G.As
M.Error
M.Unwrap
T.Scan
U
F
F.Error
W.Error
M
U.WriteTo.w
V.Is
V.Unwrap
G
F.Is
W.Unwrap
xml
io
T.Format
E.Error
U.GobDecode
U.WriteTo
T.WriteTo.more
E.As
E.Is
T
T.Scan.c
T.WriteTo
T.WriteTo.args
fmt
U.Format
I
E.Unwrap
Members
X