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

vndr init produces wrong vendor.conf for versioned packages #88

Open
AkihiroSuda opened this issue Jan 10, 2020 · 2 comments
Open

vndr init produces wrong vendor.conf for versioned packages #88

AkihiroSuda opened this issue Jan 10, 2020 · 2 comments

Comments

@AkihiroSuda
Copy link
Contributor

AkihiroSuda commented Jan 10, 2020

$ cat foo.go
package foo

import (
        "github.com/containerd/cgroups/v2"
)

func Foo(a, b string) (*v2.Manager, error) {
        return v2.LoadManager(a, b)
}
$ vndr init

Result:

github.com/containerd/cgroups/v2 3f83850c48d225466698517ad34f4848d2ddaeeb
github.com/containerd/cgroups/stats/v1 3f83850c48d225466698517ad34f4848d2ddaeeb
github.com/coreos/go-systemd d657f9650837651364841f00795b417b1ca43c1f
github.com/docker/go-units 519db1ee28dcc9fd2474ae59fca29a810482bfb1
github.com/godbus/dbus/v5 43c7e6d0673024b2dcdf97cb4d766efec9da7e9b
github.com/opencontainers/runtime-spec e09c7c488e298f2147734e657eba72fc9fa10ca9
github.com/pkg/errors 49f8f617296114c890ae0b7ac18c5953d2b1ca0f
golang.org/x/sys 548cf772de5052aa878ccb47cdeb7d262b75c8ec
github.com/coreos/go-systemd d657f9650837651364841f00795b417b1ca43c1f

Expected result:

github.com/containerd/cgroups 3f83850c48d225466698517ad34f4848d2ddaeeb
github.com/coreos/go-systemd/v22 d657f9650837651364841f00795b417b1ca43c1f
...

Note:

  • github.com/containerd/cgroups in vendor.conf MUST NOT contain /v2 suffix because v2 is a git subdirectory, not a version string in go.mod
  • github.com/coreos/go-systemd/v22 MUST contain /v22 suffix because v22 is a version string in go.mod, not a git subdirectory

I'm not sure how we can support this without parsing go.mod.

vndr version 0.1.0

@thaJeztah
Copy link
Collaborator

Looks like the package for parsing gomod is "internal" 😞 https://golang.org/pkg/cmd/go/internal/modfile/

Looking at other projects, there are valid use-cases to use that package though, for example; I found this project to run a go proxy, which looks to copy those files in order to use them; https://github.com/sirkon/goproxy/blob/bac7c5e34d4e2ec415275c4f2ddc5c1c86e74fd6/internal/modfile/read.go. Haven't looked yet, but perhaps we should propose that package to not be marked "internal"

nevermind: looks like it moved to golang.org/x/mod: https://github.com/golang/mod/blob/c90efee705eefc6efa975842f5e85f455b0b4639/modfile/read.go

@LK4D4
Copy link
Owner

LK4D4 commented Jan 10, 2020

@AkihiroSuda that's a bummer. I wonder if it's easy to detect and produce warnings. Thanks for taking a look.

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

No branches or pull requests

3 participants