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

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

Comments

Projects
None yet
4 participants
@gopherbot

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

This comment has been minimized.

Show comment Hide comment
@alberts

alberts Jan 9, 2013

Contributor

Comment 1:

issue #2775, more or less...
Contributor

alberts commented Jan 9, 2013

Comment 1:

issue #2775, more or less...
@davecheney

This comment has been minimized.

Show comment Hide comment
@davecheney

davecheney Jan 9, 2013

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.

Contributor

davecheney commented Jan 9, 2013

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

@gopherbot gopherbot 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.