mage icon indicating copy to clipboard operation
mage copied to clipboard

Named imports not working with Aliases

Open andrewkroh opened this issue 5 years ago • 1 comments

I think I found a small bug that occurs when using a PackageName in an import declaration and declaring an alias that references that package. It seems that the Name from the ast.ImportSpec isn't stored when parsing.

// +build mage

package main

import (
	"github.com/andrewkroh/project/common/mage"

	// mage:import
	subproject "github.com/andrewkroh/project/subproject/mage"
)

var Aliases = map[string]interface{}{
	"update": subproject.Update.All,
}

...

This results in an error like:

2018/12/31 02:17:01 warning, alias malformed: unknown package for function &{%!q(*ast.SelectorExpr=&{0xc000099440 0xc000099460}) "All"}

I can probably cook up a test case if that helps.

andrewkroh avatar Dec 31 '18 07:12 andrewkroh

oops, yeah, that sounds like a bug. Thanks!

natefinch avatar Jan 23 '19 16:01 natefinch