...
Run Format

Package testdata

import "cmd/vet/testdata"
Overview
Index

Overview ▾

Index ▾

Variables
func AcceptedCases()
func AtomicTests()
func AtomicTypesCheck()
func Bad(CustomLock)
func BadFunc(FieldMutex, int)
func BadFunc2(sync.Map)
func BadRet() sync.Mutex
func Comparison()
func DisableErrorForFlag0()
func F()
func FuncCallInterfaceArg(f func(a int, b interface{}))
func LenAndCapOnLockArrays()
func NonAtomic()
func Ok(*CustomLock)
func OkFunc(*FieldMutex)
func OkRet() *sync.Mutex
func PrintfTests()
func RangeLoopTests()
func RatherStupidConditions()
func ReturnViaInterface(x int) (int, interface{})
func RoyallySuspectConditions()
func ShadowRead(f *os.File, buf []byte) (err error)
func ShiftDeadCode()
func ShiftTest()
func SizeofMutex()
func StillOk(EmbeddedMutexPointer)
func SyncTypesCheck()
func UnexportedStringerOrError()
func UnsafePointerPrintfTest()
type AnonymousJSON
type AnonymousXML
type BoolFormatter
    func (*BoolFormatter) Format(fmt.State, rune)
type Counter
type CustomLock
    func (*CustomLock) Lock()
    func (*CustomLock) Unlock()
type DuplicateJSONFields
type EmbeddedLocker
    func (EmbeddedLocker) AlsoOk()
    func (*EmbeddedLocker) Ok()
type EmbeddedMutexPointer
    func LookinGood() EmbeddedMutexPointer
    func (EmbeddedMutexPointer) AlsoOk()
    func (*EmbeddedMutexPointer) Ok()
type EmbeddedRWMutex
    func BadRet() EmbeddedRWMutex
    func OkRet() *EmbeddedRWMutex
    func (EmbeddedRWMutex) BadMeth()
    func (*EmbeddedRWMutex) OkMeth()
type FT
type FieldMutex
    func (FieldMutex) BadMeth()
    func (*FieldMutex) OkMeth()
type FormatterVal
    func (FormatterVal) Format(fmt.State, rune)
type JSONEmbeddedField
type L0
    func (L0) Bad()
    func (*L0) Ok()
type L1
type L2
type LocalMutex
    func (LocalMutex) Bad()
type LocalOnce
    func (LocalOnce) Bad()
type MethodTest
    func (t *MethodTest) Scan(x fmt.ScanState, c byte)
type MethodTestInterface
type MyStruct
type RecursiveMap
type RecursiveSlice
type RecursiveStruct
type RecursiveStruct1
type RecursiveStruct2
type ST
    func (s *ST) SetX(x int, ch chan int)
type SliceHeader
type StringHeader
type StructTagTest
type T
    func (T) AddUint64(addr *uint64, delta uint64) uint64
    func (t T) Foo() int
    func (T) M()
type Tlock
type UnexpectedSpacetest
type UnexportedEncodingTagTest
type V

Package files

assign.go atomic.go bool.go composite.go copylock.go copylock_func.go copylock_range.go httpresponse.go lostcancel.go method.go nilfunc.go print.go rangeloop.go shadow.go shift.go structtag.go unsafeptr.go unused.go

Variables

var (
        OkClosure   = func(*sync.Mutex) {}
        BadClosure  = func(sync.Mutex) {} // ERROR "func passes lock by value: sync.Mutex"
        BadClosure2 = func(sync.Map) {}   // ERROR "func passes lock by value: sync.Map contains sync.Mutex"
)
var Fv = F
var Okay1 = []string{
        "Name",
        "Usage",
        "DefValue",
}
var Okay2 = map[string]bool{
        "Name":     true,
        "Usage":    true,
        "DefValue": true,
}
var Okay3 = struct {
        X string
        Y string
        Z string
}{
        "Name",
        "Usage",
        "DefValue",
}
var Okay4 = []struct {
        A int
        B int
}{
        {1, 2},
        {3, 4},
}
var Okay5 = &MyStruct{
        "Name",
        "Usage",
        "DefValue",
}
var Okay6 = []MyStruct{
        {"foo", "bar", "baz"},
        {"aa", "bb", "cc"},
}
var Okay7 = []*MyStruct{
        {"foo", "bar", "baz"},
        {"aa", "bb", "cc"},
}
var S []int

func AcceptedCases

func AcceptedCases()

func AtomicTests

func AtomicTests()

func AtomicTypesCheck

func AtomicTypesCheck()

AtomicTypesCheck checks copying of sync/atomic types

func Bad

func Bad(CustomLock)

func BadFunc

func BadFunc(FieldMutex, int)

func BadFunc2

func BadFunc2(sync.Map)

func BadRet

func BadRet() sync.Mutex

func Comparison

func Comparison()

func DisableErrorForFlag0

func DisableErrorForFlag0()

TODO: Disable complaint about '0' for Go 1.10. To be fixed properly in 1.11. See issues 23598 and 23605.

func F

func F()

func FuncCallInterfaceArg

func FuncCallInterfaceArg(f func(a int, b interface{}))

Passing lock values into interface function arguments

func LenAndCapOnLockArrays

func LenAndCapOnLockArrays()

func NonAtomic

func NonAtomic()

func Ok

func Ok(*CustomLock)

func OkFunc

func OkFunc(*FieldMutex)

func OkRet

func OkRet() *sync.Mutex

func PrintfTests

func PrintfTests()

This function never executes, but it serves as a simple test for the program. Test with make test.

func RangeLoopTests

func RangeLoopTests()

func RatherStupidConditions

func RatherStupidConditions()

func ReturnViaInterface

func ReturnViaInterface(x int) (int, interface{})

Returning lock via interface value

func RoyallySuspectConditions

func RoyallySuspectConditions()

func ShadowRead

func ShadowRead(f *os.File, buf []byte) (err error)

func ShiftDeadCode

func ShiftDeadCode()

func ShiftTest

func ShiftTest()

func SizeofMutex

func SizeofMutex()

func StillOk

func StillOk(EmbeddedMutexPointer)

func SyncTypesCheck

func SyncTypesCheck()

SyncTypesCheck checks copying of sync.* types except sync.Mutex

func UnexportedStringerOrError

func UnexportedStringerOrError()

func UnsafePointerPrintfTest

func UnsafePointerPrintfTest()

type AnonymousJSON

type AnonymousJSON struct{}

type AnonymousXML

type AnonymousXML struct{}

type BoolFormatter

type BoolFormatter bool

func (*BoolFormatter) Format

func (*BoolFormatter) Format(fmt.State, rune)

type Counter

type Counter uint64

type CustomLock

type CustomLock struct{}

func (*CustomLock) Lock

func (*CustomLock) Lock()

func (*CustomLock) Unlock

func (*CustomLock) Unlock()

type DuplicateJSONFields

type DuplicateJSONFields struct {
        JSON              int `json:"a"`
        DuplicateJSON     int `json:"a"` // ERROR "struct field DuplicateJSON repeats json tag .a. also at structtag.go:46"
        IgnoredJSON       int `json:"-"`
        OtherIgnoredJSON  int `json:"-"`
        OmitJSON          int `json:",omitempty"`
        OtherOmitJSON     int `json:",omitempty"`
        DuplicateOmitJSON int `json:"a,omitempty"` // ERROR "struct field DuplicateOmitJSON repeats json tag .a. also at structtag.go:46"
        NonJSON           int `foo:"a"`
        DuplicateNonJSON  int `foo:"a"`
        Embedded          struct {
                DuplicateJSON int `json:"a"` // OK because its not in the same struct type
        }
        AnonymousJSON `json:"a"` // ERROR "struct field AnonymousJSON repeats json tag .a. also at structtag.go:46"

        XML              int `xml:"a"`
        DuplicateXML     int `xml:"a"` // ERROR "struct field DuplicateXML repeats xml tag .a. also at structtag.go:60"
        IgnoredXML       int `xml:"-"`
        OtherIgnoredXML  int `xml:"-"`
        OmitXML          int `xml:",omitempty"`
        OtherOmitXML     int `xml:",omitempty"`
        DuplicateOmitXML int `xml:"a,omitempty"` // ERROR "struct field DuplicateOmitXML repeats xml tag .a. also at structtag.go:60"
        NonXML           int `foo:"a"`
        DuplicateNonXML  int `foo:"a"`
        Embedded         struct {
                DuplicateXML int `xml:"a"` // OK because its not in the same struct type
        }
        AnonymousXML `xml:"a"` // ERROR "struct field AnonymousXML repeats xml tag .a. also at structtag.go:60"
        Attribute    struct {
                XMLName     xml.Name `xml:"b"`
                NoDup       int      `xml:"b"`                // OK because XMLName above affects enclosing struct.
                Attr        int      `xml:"b,attr"`           // OK because <b b="0"><b>0</b></b> is valid.
                DupAttr     int      `xml:"b,attr"`           // ERROR "struct field DupAttr repeats xml attribute tag .b. also at structtag.go:76"
                DupOmitAttr int      `xml:"b,omitempty,attr"` // ERROR "struct field DupOmitAttr repeats xml attribute tag .b. also at structtag.go:76"

                AnonymousXML `xml:"b,attr"` // ERROR "struct field AnonymousXML repeats xml attribute tag .b. also at structtag.go:76"
        }
}

type EmbeddedLocker

type EmbeddedLocker struct {
        sync.Locker // safe to copy interface values
}

func (EmbeddedLocker) AlsoOk

func (EmbeddedLocker) AlsoOk()

func (*EmbeddedLocker) Ok

func (*EmbeddedLocker) Ok()

type EmbeddedMutexPointer

type EmbeddedMutexPointer struct {
        // contains filtered or unexported fields
}

func LookinGood

func LookinGood() EmbeddedMutexPointer

func (EmbeddedMutexPointer) AlsoOk

func (EmbeddedMutexPointer) AlsoOk()

func (*EmbeddedMutexPointer) Ok

func (*EmbeddedMutexPointer) Ok()

type EmbeddedRWMutex

type EmbeddedRWMutex struct {
        sync.RWMutex
}

func BadRet

func BadRet() EmbeddedRWMutex

func OkRet

func OkRet() *EmbeddedRWMutex

func (EmbeddedRWMutex) BadMeth

func (EmbeddedRWMutex) BadMeth()

func (*EmbeddedRWMutex) OkMeth

func (*EmbeddedRWMutex) OkMeth()

type FT

type FT func() int

type FieldMutex

type FieldMutex struct {
        // contains filtered or unexported fields
}

func (FieldMutex) BadMeth

func (FieldMutex) BadMeth()

func (*FieldMutex) OkMeth

func (*FieldMutex) OkMeth()

type FormatterVal

Formatter with value receiver

type FormatterVal bool

func (FormatterVal) Format

func (FormatterVal) Format(fmt.State, rune)

type JSONEmbeddedField

type JSONEmbeddedField struct {
        UnexportedEncodingTagTest `is:"embedded"`
        // contains filtered or unexported fields
}

type L0

type L0 struct {
        L1
}

func (L0) Bad

func (L0) Bad()

func (*L0) Ok

func (*L0) Ok()

type L1

type L1 struct {
        // contains filtered or unexported fields
}

type L2

type L2 struct {
        sync.Mutex
}

type LocalMutex

False negative: LocalMutex doesn't have a Lock method. Nevertheless, it is probably a bad idea to pass it by value.

type LocalMutex sync.Mutex

func (LocalMutex) Bad

func (LocalMutex) Bad()

type LocalOnce

Non-ideal error message: Since we're looking for Lock methods, sync.Once's underlying sync.Mutex gets called out, but without any reference to the sync.Once.

type LocalOnce sync.Once

func (LocalOnce) Bad

func (LocalOnce) Bad()

type MethodTest

type MethodTest int

func (*MethodTest) Scan

func (t *MethodTest) Scan(x fmt.ScanState, c byte)

type MethodTestInterface

type MethodTestInterface interface {
        ReadByte() byte // ERROR "should have signature ReadByte"
}

type MyStruct

type MyStruct struct {
        X string
        Y string
        Z string
}

type RecursiveMap

type RecursiveMap map[int]RecursiveMap

type RecursiveSlice

type RecursiveSlice []RecursiveSlice

type RecursiveStruct

type RecursiveStruct struct {
        // contains filtered or unexported fields
}

type RecursiveStruct1

type RecursiveStruct1 struct {
        // contains filtered or unexported fields
}

type RecursiveStruct2

type RecursiveStruct2 struct {
        // contains filtered or unexported fields
}

type ST

type ST struct {
        // contains filtered or unexported fields
}

func (*ST) SetX

func (s *ST) SetX(x int, ch chan int)

type SliceHeader

type SliceHeader struct {
        Data uintptr
}

type StringHeader

type StringHeader struct {
        Data uintptr
}

type StructTagTest

type StructTagTest struct {
        A   int "hello"            // ERROR "not compatible with reflect.StructTag.Get: bad syntax for struct tag pair"
        B   int "\tx:\"y\""        // ERROR "not compatible with reflect.StructTag.Get: bad syntax for struct tag key"
        C   int "x:\"y\"\tx:\"y\"" // ERROR "not compatible with reflect.StructTag.Get"
        D   int "x:`y`"            // ERROR "not compatible with reflect.StructTag.Get: bad syntax for struct tag value"
        E   int "ct\brl:\"char\""  // ERROR "not compatible with reflect.StructTag.Get: bad syntax for struct tag pair"
        F   int `:"emptykey"`      // ERROR "not compatible with reflect.StructTag.Get: bad syntax for struct tag key"
        G   int `x:"noEndQuote`    // ERROR "not compatible with reflect.StructTag.Get: bad syntax for struct tag value"
        H   int `x:"trunc\x0"`     // ERROR "not compatible with reflect.StructTag.Get: bad syntax for struct tag value"
        I   int `x:"foo",y:"bar"`  // ERROR "not compatible with reflect.StructTag.Get: key:.value. pairs not separated by spaces"
        J   int `x:"foo"y:"bar"`   // ERROR "not compatible with reflect.StructTag.Get: key:.value. pairs not separated by spaces"
        OK0 int `x:"y" u:"v" w:""`
        OK1 int `x:"y:z" u:"v" w:""` // note multiple colons.
        OK2 int "k0:\"values contain spaces\" k1:\"literal\ttabs\" k2:\"and\\tescaped\\tabs\""
        OK3 int `under_scores:"and" CAPS:"ARE_OK"`
}

type T

type T struct {
        F func()
}

func (T) AddUint64

func (T) AddUint64(addr *uint64, delta uint64) uint64

func (T) Foo

func (t T) Foo() int

func (T) M

func (T) M()

type Tlock

type Tlock struct {
        // contains filtered or unexported fields
}

type UnexpectedSpacetest

type UnexpectedSpacetest struct {
        A int `json:"a,omitempty"`
        B int `json:"b, omitempty"` // ERROR "suspicious space in struct tag value"
        C int `json:"c ,omitempty"`
        D int `json:"d,omitempty, string"` // ERROR "suspicious space in struct tag value"
        E int `xml:"e local"`
        F int `xml:"f "`                 // ERROR "suspicious space in struct tag value"
        G int `xml:" g"`                 // ERROR "suspicious space in struct tag value"
        H int `xml:"h ,omitempty"`       // ERROR "suspicious space in struct tag value"
        I int `xml:"i, omitempty"`       // ERROR "suspicious space in struct tag value"
        J int `xml:"j local ,omitempty"` // ERROR "suspicious space in struct tag value"
        K int `xml:"k local, omitempty"` // ERROR "suspicious space in struct tag value"
        L int `xml:" l local,omitempty"` // ERROR "suspicious space in struct tag value"
        M int `xml:"m  local,omitempty"` // ERROR "suspicious space in struct tag value"
        N int `xml:" "`                  // ERROR "suspicious space in struct tag value"
        O int `xml:""`
        P int `xml:","`
        Q int `foo:" doesn't care "`
}

type UnexportedEncodingTagTest

type UnexportedEncodingTagTest struct {
        A int `json:"aa" xml:"bb"`
        // contains filtered or unexported fields
}

type V

type V interface {
        Pointer() uintptr
        UnsafeAddr() uintptr
}