Skip to content
This repository has been archived by the owner on Mar 6, 2020. It is now read-only.

Binary target dir name has a "-" instead of "_" #634

Open
pfeairheller opened this issue Jul 6, 2016 · 4 comments
Open

Binary target dir name has a "-" instead of "_" #634

pfeairheller opened this issue Jul 6, 2016 · 4 comments

Comments

@pfeairheller
Copy link

pfeairheller commented Jul 6, 2016

At line 300 of gb/context.go, gb is creating the target dir name based on architecture and os by concatenating them with a "-" instead of the (seemingly?) standard "_". Here is the relevant function:

// ctxString returns a string representation of the unique properties
// of the context.
func (c *Context) ctxString() string {
    v := []string{
        c.gotargetos,
        c.gotargetarch,
    }
    v = append(v, c.buildtags...)
    return strings.Join(v, "-")
}

This is causing issue with our code generators that use the "types" package and the default importer with the following:

conf := types.Config{Importer: importer.Default()}

The default importer uses built binaries to discover dependencies and since they are in a pkg directory (darwin-amd64 in our case) with the "-" instead of the "_", it can't find any of our code.

Was the use of the "-" intentional? Would it be possible to change it to an "_" to match the what the go/importer lib expects?

Thank you.

@davecheney
Copy link
Contributor

Yes, the - is intentional to avoid overwriting .a files created by the go tool.

@gandalfSievers
Copy link

gandalfSievers commented Jan 16, 2018

This causes problems when using go vet. It needs the imports as binaries in order to perform all checks. At the moment go vet just silently ignores the missing binaries and exits with 0, if you don't use -v to find that it says something like

src/foo/bar.go:7:2: could not import baz/foz (can't find import: "baz/foz")

While it would find an error like:

src/foo/bar.go:191: baz/foz.MyType composite literal uses unkeyed fields

and exit with 1 if it can discover the binaries.

@davecheney
Copy link
Contributor

davecheney commented May 18, 2018 via email

@paraboul
Copy link

@davecheney My post was actually for another project referencing this issue :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants