magefile / mage

a Make/rake-like dev tool using Go
https://magefile.org
Apache License 2.0
4.12k stars 251 forks source link

Bug: using Default with imports selects first matching func by name #508

Open na4ma4 opened 3 months ago

na4ma4 commented 3 months ago

Bug Description When using imports, namespaces and Default, the getFunction() function will return the first matching function in the import with the same name, regardless of namespacing.

So

// project magefile.go
var Default = mage.Test

// imported repo

type Docker mg.Namespace

func (Docker) Test() {
    log.Println("docker")
}

func Test() {
    log.Println("test")
}

Will find Docker.Test() before Test().

What did you do?

Created a test repository as an example

What did you expect to happen?

$ mage
test

What actually happened?

$ mage
docker

Environment

Additional context

natefinch commented 3 months ago

ooh, thanks for the report and the repro steps

na4ma4 commented 1 month ago

I did a PR as well to fix it #509