Skip to content

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

@gopherbot

Description

@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 ?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions