Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why "go build" depends on $GOROOT/src/pkg #4635

Closed
gopherbot opened this issue Jan 9, 2013 · 2 comments
Closed

Why "go build" depends on $GOROOT/src/pkg #4635

gopherbot opened this issue Jan 9, 2013 · 2 comments
Milestone

Comments

@gopherbot
Copy link

by xuxinhua1984:

The code is:(test.go)
package main
import "fmt"
func main() {
    fmt.Println("Hello, World")
}

Then, I build it: go build test.go. It is OK.

But when I delete $GOROOT/src/pkg/fmt directory, then build test.go, it failed:
cannot find package "fmt" in any of:
    /usr/local/go/src/pkg/fmt (from $GOROOT)

However, I can build it by 6g and link it by 6l:
   go tool 6g test.go
   go tool 6l test.6
this will generate 6.out

Why "go build" depends on $GOROOT/src/pkg ?
@alberts
Copy link
Contributor

alberts commented Jan 9, 2013

Comment 1:

issue #2775, more or less...

@davecheney
Copy link
Contributor

Comment 2:

The go tool currently requires the source to be present, even if the compiled package is
present. There is a workaround, if you leave an empty directory, _with_ an mtime older
than the compiled package, in src/ then the go tool _should_ work.

Status changed to Duplicate.

Merged into issue #2775.

@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants