github.com/golang/mock@v1.6.0/mockgen/internal/tests/aux_imports_embedded_interface/README.md (about) 1 # Embedded Interfaces in aux_files 2 3 Embedded interfaces in `aux_files` generate `unknown embedded interface XXX` errors. 4 See below for example of the problem: 5 6 ```go 7 // source 8 import ( 9 alias "some.org/package/imported" 10 ) 11 12 type Source interface { 13 alias.Foreign 14 } 15 ``` 16 17 ```go 18 // some.org/package/imported 19 type Foreign interface { 20 Embedded 21 } 22 23 type Embedded interface {} 24 ``` 25 26 Attempting to generate a mock will result in an `unknown embedded interface Embedded`. 27 The issue is that the `fileParser` stores `auxInterfaces` underneath the package name 28 explicitly specified in the `aux_files` flag. 29 30 In the `parseInterface` method, there is an incorrect assumption about an embedded interface 31 always being in the source file. 32 33 ```go 34 case *ast.Ident: 35 // Embedded interface in this package. 36 ei := p.auxInterfaces[""][v.String()] 37 if ei == nil { 38 return nil, p.errorf(v.Pos(), "unknown embedded interface %s", v.String()) 39 } 40 ```