Skip to content

Commit

Permalink
feat: allow mage:import alias to be defined for multiple imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Viktor Voltaire committed Dec 22, 2021
1 parent 2f1ec40 commit 7cb490b
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions parse/parse.go
Expand Up @@ -267,7 +267,7 @@ func Package(path string, files []string) (*PkgInfo, error) {

func getNamedImports(gocmd string, pkgs map[string]string) ([]*Import, error) {
var imports []*Import
for alias, pkg := range pkgs {
for pkg, alias := range pkgs {
debug.Printf("getting import package %q, alias %q", pkg, alias)
imp, err := getImport(gocmd, pkg, alias)
if err != nil {
Expand Down Expand Up @@ -411,10 +411,7 @@ func setImports(gocmd string, pi *PkgInfo) error {
}
if alias != "" {
debug.Printf("found %s: %s (%s)", importTag, name, alias)
if importNames[alias] != "" {
return fmt.Errorf("duplicate import alias: %q", alias)
}
importNames[alias] = name
importNames[name] = alias
} else {
debug.Printf("found %s: %s", importTag, name)
rootImports = append(rootImports, name)
Expand Down

0 comments on commit 7cb490b

Please sign in to comment.