Skip to content

-gocmd should pass MAGEFILE_GOCMD to the Magefile #208

@ihgann

Description

@ihgann

As mentioned in #207, if a user sets -gocmd when running their magefile, the go runtime they pass in is not actually available to the Magefile. It seems, instead, the setting is only used for compiling the magefile, but is not actually transferred into the magefile.

For example, if my magefile has the following target:

func GoRuntime() {
    fmt.Printf("Go Runtime is: %s", mg.GoCmd())
}

If I run mage goRuntime, as expected, I receive the output:

Go Runtime is: go

However, if I run mage -gocmd /usr/local/bin/go goRuntime, I still receive the above output - but it should be:

Go Runtime is: /usr/local/bin/go

When running with --debug (i.e. mage -gocmd /usr/local/bin/go --debug goRuntime, I receive the following logs:

DEBUG: 16:31:45.427534 running magefile with mage vars:
MAGEFILE_DEBUG=1
Go Runtime is: go

I believe -gocmd should set the environment variable MAGEFILE_GOCMD before running the magefile in order to have GoCmd() function properly within the magefile.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions