| 1 |
// errorcheck |
| 2 |
|
| 3 |
// Copyright 2019 The Go Authors. All rights reserved. |
| 4 |
// Use of this source code is governed by a BSD-style |
| 5 |
// license that can be found in the LICENSE file. |
| 6 |
|
| 7 |
package p |
| 8 |
|
| 9 |
import "./f1" |
| 10 |
|
| 11 |
func main() { |
| 12 |
f := f1.Foo{ |
| 13 |
doneChan: nil, // ERROR "cannot refer to unexported field 'doneChan' in struct literal of type f1.Foo" |
| 14 |
DoneChan: nil, // ERROR "unknown field 'DoneChan' in struct literal of type f1.Foo" |
| 15 |
Name: "hey", |
| 16 |
name: "there", // ERROR "unknown field 'name' in struct literal of type f1.Foo .but does have Name." |
| 17 |
noSuchPrivate: true, // ERROR "unknown field 'noSuchPrivate' in struct literal of type f1.Foo" |
| 18 |
NoSuchPublic: true, // ERROR "unknown field 'NoSuchPublic' in struct literal of type f1.Foo" |
| 19 |
foo: true, // ERROR "unknown field 'foo' in struct literal of type f1.Foo" |
| 20 |
hook: func() {}, // ERROR "cannot refer to unexported field 'hook' in struct literal of type f1.Foo" |
| 21 |
unexported: func() {}, // ERROR "unknown field 'unexported' in struct literal of type f1.Foo" |
| 22 |
Exported: func() {}, // ERROR "unknown field 'Exported' in struct literal of type f1.Foo" |
| 23 |
} |
| 24 |
f.doneChan = nil // ERROR "f.doneChan undefined .cannot refer to unexported field or method doneChan." |
| 25 |
f.DoneChan = nil // ERROR "f.DoneChan undefined .type f1.Foo has no field or method DoneChan." |
| 26 |
f.name = nil // ERROR "f.name undefined .type f1.Foo has no field or method name, but does have Name." |
| 27 |
|
| 28 |
_ = f.doneChan // ERROR "f.doneChan undefined .cannot refer to unexported field or method doneChan." |
| 29 |
_ = f.DoneChan // ERROR "f.DoneChan undefined .type f1.Foo has no field or method DoneChan." |
| 30 |
_ = f.Name |
| 31 |
_ = f.name // ERROR "f.name undefined .type f1.Foo has no field or method name, but does have Name." |
| 32 |
_ = f.noSuchPrivate // ERROR "f.noSuchPrivate undefined .type f1.Foo has no field or method noSuchPrivate." |
| 33 |
_ = f.NoSuchPublic // ERROR "f.NoSuchPublic undefined .type f1.Foo has no field or method NoSuchPublic." |
| 34 |
_ = f.foo // ERROR "f.foo undefined .type f1.Foo has no field or method foo." |
| 35 |
_ = f.Exported |
| 36 |
_ = f.exported // ERROR "f.exported undefined .type f1.Foo has no field or method exported, but does have Exported." |
| 37 |
_ = f.Unexported // ERROR "f.Unexported undefined .type f1.Foo has no field or method Unexported." |
| 38 |
_ = f.unexported // ERROR "f.unexported undefined .cannot refer to unexported field or method unexported." |
| 39 |
f.unexported = 10 // ERROR "f.unexported undefined .cannot refer to unexported field or method unexported." |
| 40 |
f.unexported() // ERROR "f.unexported undefined .cannot refer to unexported field or method unexported." |
| 41 |
_ = f.hook // ERROR "f.hook undefined .cannot refer to unexported field or method hook." |
| 42 |
} |