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

x/tools/go/loader: needs to be updated to stdlib go/types #11861

Closed
sbinet opened this issue Jul 24, 2015 · 11 comments
Closed

x/tools/go/loader: needs to be updated to stdlib go/types #11861

sbinet opened this issue Jul 24, 2015 · 11 comments

Comments

@sbinet
Copy link
Member

sbinet commented Jul 24, 2015

hi,

with the upcoming go-1.5 and the import of (a modified version of) the x/tools/go/types package into the stdlib, golang.org/x/tools/go/loader needs to be updated.

the following program will fail to compile:

package main

import (
    "fmt"
    "go/build"
    "go/token"
    "go/types"
    "log"
    "os"

    "golang.org/x/tools/go/loader"
)

func main() {
    path := os.Args[1]
    fmt.Printf(">>> inspecting [%s]...\n", path)

    cwd, err := os.Getwd()
    if err != nil {
        log.Panicf("error: %v\n", err)
    }

    pkg, err := build.Import(path, cwd, 0)
    if err != nil {
        log.Panicf("error: %v\n", err)
    }

    conf := loader.Config{
        Fset: token.NewFileSet(),
    }

    prog, err := conf.Load()
    if err != nil {
        log.Panicf("error: %v\n", err)
    }

    var p *types.Package = prog.Created[0].Pkg
    fmt.Printf("pkg=%v\n", p)
}

with the following error:

sh> go run foo.go github.com/go-python/gopy/_examples/hi
# command-line-arguments
./foo.go:39: cannot use prog.Created[0].Pkg (type *"golang.org/x/tools/go/types".Package) as type *"go/types".Package in assignment
@sbinet
Copy link
Member Author

sbinet commented Jul 24, 2015

FYI, I have been testing this against golang/tools@1c460ff and d23973d.

@josharian
Copy link
Contributor

This is one of the unfortunate things about having two versions of the same packages. If this were to get fixed, then folks using the x/tools go/types would have breakage the other direction.

/cc @alandonovan @griesemer

@ianlancetaylor ianlancetaylor added this to the Go1.5 milestone Jul 24, 2015
@ianlancetaylor
Copy link
Member

We should be able to use build tags in x/tools to make this work.

@sbinet
Copy link
Member Author

sbinet commented Jul 24, 2015

using a go-1.5 build tag sounds good.
I can send a CL if nobody beats me to it.

@ianlancetaylor ianlancetaylor changed the title [tools] go/loader needs to be updated to stdlib go/types x/tools/go/loader: needs to be updated to stdlib go/types Jul 24, 2015
@alandonovan
Copy link
Contributor

I agree this needs to happen, but we cannot change the tools repo until after Go 1.5 has been released and has settled for at least a while. My plan is to update the whole tools repo in early September so that it no longer uses tools/go/types (though of course that package will remain there).

@dsymonds
Copy link
Contributor

If build tags are used, there's no need to wait for Go 1.5. This is also not tied to the release.

@dsymonds dsymonds removed this from the Go1.5 milestone Jul 27, 2015
@adonovan
Copy link
Member

Fully one third of the ~350 *.go files in the tools repo import golang.org/x/tools/go/types. Are you suggesting that I make go1.5-tagged duplicates of all those files, and maintain them in parallel during several months of anticipated heavy churn? Or something else?

@dsymonds
Copy link
Contributor

I didn't realise it was that many files. Yeah, build tags seem inappropriate. Let's just do the change after the release.

@dmitshur
Copy link
Contributor

My plan is to update the whole tools repo in early September so that it no longer uses tools/go/types (though of course that package will remain there).

@adonovan, has that been done already, or not yet? If not, is there an updated estimate for when it'll happen?

@alandonovan
Copy link
Contributor

I (finally) sent https://go-review.googlesource.com/#/c/18207/ for review today. I'll submit it after the holiday since it will require that all clients using tip (not go1.5) update to go/types too.

@dmitshur
Copy link
Contributor

dmitshur commented Jan 7, 2016

This issue has been resolved via golang/tools@542ffc7 and can be closed.

@golang golang locked and limited conversation to collaborators Feb 28, 2017
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

10 participants