File: README.md

package info (click to toggle)
golang-go.uber-mock 0.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,176 kB
  • sloc: sh: 37; makefile: 3
file content (40 lines) | stat: -rw-r--r-- 974 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# Embedded Interfaces in aux_files

Embedded interfaces in `aux_files` generate `unknown embedded interface XXX` errors.
See below for example of the problem:

```go
// source
import (
    alias "some.org/package/imported"
)

type Source interface {
    alias.Foreign
}
```

```go
// some.org/package/imported
type Foreign interface {
    Embedded
}

type Embedded interface {}
```

Attempting to generate a mock will result in an `unknown embedded interface Embedded`.
The issue is that the `fileParser` stores `auxInterfaces` underneath the package name
explicitly specified in the `aux_files` flag.

In the `parseInterface` method, there is an incorrect assumption about an embedded interface
always being in the source file.

```go
case *ast.Ident:
        // Embedded interface in this package.
        ei := p.auxInterfaces[""][v.String()]
        if ei == nil {
                return nil, p.errorf(v.Pos(), "unknown embedded interface %s", v.String())
        }
```