зеркало из https://github.com/golang/mock.git
Fix import name conflict resolution.
This commit is contained in:
Родитель
ed895f5bb6
Коммит
9dcd4b2cd0
|
@ -186,18 +186,20 @@ func (g *generator) Generate(pkg *model.Package, pkgName string) error {
|
|||
im := pkg.Imports()
|
||||
im[gomockImportPath] = true
|
||||
g.packageMap = make(map[string]string, len(im))
|
||||
localNames := make(map[string]bool, len(im))
|
||||
for pth := range im {
|
||||
base := sanitize(path.Base(pth))
|
||||
|
||||
// try base0, base1, ...
|
||||
pkgName := base
|
||||
i := 0
|
||||
for g.packageMap[pkgName] != "" {
|
||||
for localNames[pkgName] {
|
||||
pkgName = base + strconv.Itoa(i)
|
||||
i++
|
||||
}
|
||||
|
||||
g.packageMap[pth] = pkgName
|
||||
localNames[pkgName] = true
|
||||
}
|
||||
|
||||
g.p("package %v", pkgName)
|
||||
|
|
|
@ -12,8 +12,10 @@ import (
|
|||
imp3 "code.google.com/p/gomock/sample/imp3"
|
||||
imp4 "code.google.com/p/gomock/sample/imp4"
|
||||
hash "hash"
|
||||
template "html/template"
|
||||
io "io"
|
||||
http "net/http"
|
||||
template0 "text/template"
|
||||
)
|
||||
|
||||
// Mock of Index interface
|
||||
|
@ -211,6 +213,14 @@ func (_mr *_MockIndexRecorder) Summary(arg0, arg1 interface{}) *gomock.Call {
|
|||
return _mr.mock.ctrl.RecordCall(_mr.mock, "Summary", arg0, arg1)
|
||||
}
|
||||
|
||||
func (_m *MockIndex) Templates(_param0 template.CSS, _param1 template0.FuncMap) {
|
||||
_m.ctrl.Call(_m, "Templates", _param0, _param1)
|
||||
}
|
||||
|
||||
func (_mr *_MockIndexRecorder) Templates(arg0, arg1 interface{}) *gomock.Call {
|
||||
return _mr.mock.ctrl.RecordCall(_mr.mock, "Templates", arg0, arg1)
|
||||
}
|
||||
|
||||
// Mock of Embed interface
|
||||
type MockEmbed struct {
|
||||
ctrl *gomock.Controller
|
||||
|
|
|
@ -9,6 +9,10 @@ import (
|
|||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
|
||||
// Two imports with the same base name.
|
||||
t1 "html/template"
|
||||
t2 "text/template"
|
||||
)
|
||||
|
||||
// Dependencies outside the standard library.
|
||||
|
@ -30,6 +34,7 @@ type Index interface {
|
|||
// Check that imports are handled correctly.
|
||||
Summary(buf *btz.Buffer, w io.Writer)
|
||||
Other() hash.Hash
|
||||
Templates(a t1.CSS, b t2.FuncMap)
|
||||
|
||||
// A method with an anonymous argument.
|
||||
Anon(string)
|
||||
|
|
Загрузка…
Ссылка в новой задаче