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

go/build: reject Import("", ...) #3889

Closed
gopherbot opened this issue Jul 31, 2012 · 3 comments
Closed

go/build: reject Import("", ...) #3889

gopherbot opened this issue Jul 31, 2012 · 3 comments
Milestone

Comments

@gopherbot
Copy link

by raul.san@sent.com:

build.Import is loading data about GOROOT instead of use GOPATH like I've set.

// * * *
package main

import (
    "fmt"
    "go/build"
    "log"
)

func main() {
    fmt.Println("GOROOT:", build.Default.GOROOT)
    fmt.Println("GOPATH:", build.Default.GOPATH)
    println()

    pkg, err := build.Import("", build.Default.GOPATH, build.FindOnly)
    if err != nil {
        log.Fatalf("GOROOT is not set: %s", err)
    }
    fmt.Println(pkg)
}
// * * *

GOROOT: /opt/go
GOPATH: /opt/go-3pkg:/home/under/go

&{/opt/go/src/pkg    /opt/go /opt/go/src/pkg /opt/go/pkg /opt/go/bin true
/opt/go/pkg/linux_amd64/.a [] [] [] [] [] [] [] [] [] [] map[] [] [] map[] [] [] map[]}
@rsc
Copy link
Contributor

rsc commented Sep 12, 2012

Comment 1:

Import paths found in GOROOT take precedence over import paths found in GOPATH.
You have asked for the empty import path, which should be rejected.
But since it is not rejected, and GOROOT+"/src/pkg/"+"" is a directory, Import uses that.

Labels changed: added priority-soon, removed priority-triage.

Status changed to Accepted.

@rsc
Copy link
Contributor

rsc commented Sep 12, 2012

Comment 2:

Labels changed: added go1.1.

@rsc
Copy link
Contributor

rsc commented Sep 13, 2012

Comment 3:

This issue was closed by revision ec9967f.

Status changed to Fixed.

@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

2 participants