nelsam / hel

Hel rules over Helheim, where the souls unworthy of Valhalla reside. It's also a mock generator for Go.
The Unlicense
17 stars 4 forks source link

Package aliases are not replicated in mock #13

Open myshkin5 opened 8 years ago

myshkin5 commented 8 years ago

Mock actually ends up being invalid.

Interface:

package foo

import baz "bar"

type Buz interface {
    Close() (baz.Thing)
}

Generated a mock with baz prefixes but no import for baz or bar.

nelsam commented 8 years ago

It might be surprising, but this is actually kind of a difficult problem. I kinda cheat on imports by just shelling out to goimports, but that causes all sorts of issues with aliased imports. The ideal solution (IMO) would be to strip out the aliases in the mock and just use the standardized package name, but I haven't dug into that enough to see whether or not it's easy yet.