Skip to content

cmd/go: inconsistent handling of package main importing another package main #5198

Closed
@masiulaniec

Description

@masiulaniec
The spec seems to allow package main to import another package main under another name.
However, the experience with the go tool is inconsistent:

% cd $GOPATH/src/foo
% cat a/a.go
package main

import _ "foo/b"

func init() { println("init: a") }
func main() {}
% cat b/b.go
package main

func init() { println("init: b") }
func main() {}
% rm -f $GOPATH/bin/a
% rm -f $GOPATH/bin/b
% go install ./a
% touch a/a.go
% go install ./a
# foo/a
a/a.go:3: can't find import: "foo/b"
% 

My setup:

% go env
GOARCH="amd64"
GOBIN=""
GOCHAR="6"
GOEXE=""
GOGCCFLAGS="-g -O2 -fPIC -m64 -pthread -fno-common"
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/p/go"
GOROOT="/usr/local/Cellar/go/1.0.3"
GOTOOLDIR="/usr/local/Cellar/go/1.0.3/pkg/tool/darwin_amd64"
CGO_ENABLED="1"
%

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions