replace dash with empty character in import alias name

This commit is contained in:
Alexey Baranov
2017-03-10 14:45:27 +07:00
parent db58e6f907
commit 51187256a1
+6 -1
View File
@@ -212,6 +212,11 @@ func fixPkgPathVendoring(pkgPath string) string {
return pkgPath
}
func fixAliasName(alias string) string {
alias = strings.Replace(alias, "-", "", -1)
return alias
}
// pkgAlias creates and returns and import alias for a given package.
func (g *Generator) pkgAlias(pkgPath string) string {
pkgPath = fixPkgPathVendoring(pkgPath)
@@ -220,7 +225,7 @@ func (g *Generator) pkgAlias(pkgPath string) string {
}
for i := 0; ; i++ {
alias := path.Base(pkgPath)
alias := fixAliasName(path.Base(pkgPath))
if i > 0 {
alias += fmt.Sprint(i)
}