| 1 |
Errors from attempting to import a function from another |
| 2 |
package whose body refers to unexported declarations. |
| 3 |
|
| 4 |
-- go.mod -- |
| 5 |
module testdata |
| 6 |
go 1.12 |
| 7 |
|
| 8 |
-- a/a.go -- |
| 9 |
package a |
| 10 |
|
| 11 |
func A1() { b() } |
| 12 |
func b() {} |
| 13 |
|
| 14 |
func A2() { var x T; print(x.f) } |
| 15 |
type T struct { f int } |
| 16 |
|
| 17 |
func A3() { _ = &T{f: 0} } |
| 18 |
|
| 19 |
func A4() { _ = &T{0} } |
| 20 |
|
| 21 |
-- b/b.go -- |
| 22 |
package b |
| 23 |
|
| 24 |
import "testdata/a" |
| 25 |
|
| 26 |
func _() { |
| 27 |
a.A1() //@ inline(re"A1", re`body refers to non-exported b`) |
| 28 |
a.A2() //@ inline(re"A2", re`body refers to non-exported \(testdata/a.T\).f`) |
| 29 |
a.A3() //@ inline(re"A3", re`body refers to non-exported \(testdata/a.T\).f`) |
| 30 |
a.A4() //@ inline(re"A4", re`body refers to non-exported \(testdata/a.T\).f`) |
| 31 |
} |