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

cmd/go2go: modules support #40061

Open
crawshaw opened this issue Jul 5, 2020 · 4 comments
Open

cmd/go2go: modules support #40061

crawshaw opened this issue Jul 5, 2020 · 4 comments

Comments

@crawshaw
Copy link
Contributor

@crawshaw crawshaw commented Jul 5, 2020

(Edited to use a clearer example)

The documentation for go2go says "If not found in GO2PATH, imports will be looked up in the usual way." which hints the tool is GOPATH-only. That seems to be so:

go mod init foo
go get inet.af/netaddr
go tool go2go build
foo.go2:1: cannot find package "inet.af/netaddr" in any of:
	/Users/crawshaw/repo/goroot/src/inet.af/netaddr (from $GOROOT)
	/var/folders/sc/v9m_1yq142s1yss76xc0xlqw0000gn/T/go2go017169277/src/inet.af/netaddr (from $GOPATH)
	/Users/crawshaw/go/src/inet.af/netaddr
/Users/crawshaw/repo/goroot/bin/go [build] failed: exit status 1

With foo.go2:

package main

import "inet.af/netaddr"

type S(type T) struct {
	V T
}

var s S(netaddr.IP)

func main() { }

I doubt this is worth a major effort. If it's easy though, it would be useful for experiments converting a few leaf packages in a large project.

(I have a package in tailscale's corp repository that gets easier to read and more efficient with type parameters that I would happily convert to go2go now, but it requires lifting a lot of the build system back into GOPATH.)

@ALTree ALTree added this to the Unreleased milestone Jul 6, 2020
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Jul 6, 2020

If someone wants to add module support to the tool, that would be fine with me. It's not something that I am going to work on myself. I don't think it would be easy, but perhaps I am mistaken.

@AchoArnold
Copy link

@AchoArnold AchoArnold commented Aug 16, 2020

I'm curious, Is there a workaround for this other than having to download the dependency using git?

Using the example above, I can solve it by manually downloading the package in the /Users/crawshaw/go/src/inet.af/netaddr directory. Is there a better way of making this work?

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Aug 18, 2020

Manual downloads are the only workaround. Sorry. It's an experimental tool for trying out the generics design, it's not intended for production use.

@AchoArnold
Copy link

@AchoArnold AchoArnold commented Aug 18, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.