[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Best approach to update Go packages with the version in the go import path



On Thu, Jun 18, 2020 at 2:28 PM Arnaud Rebillout
<arnaud.rebillout@collabora.com> wrote:
>
>
> On 6/12/20 8:08 AM, Arnaud Rebillout wrote:
> >
> > On 6/11/20 4:07 PM, Shengjing Zhu wrote:
> >> On Thu, Jun 11, 2020 at 4:55 PM Arnaud Rebillout
> >> <arnaud.rebillout@collabora.com> wrote:
> >>> More fun now: in the case of gotest.tools, this magic mechanism does
> >>> not work, and the build fails with multiple lines such as:
> >>>
> >>>      package gotest.tools: code in directory
> >>> /tmp/gotestdir/src/gotest.tools expects import "gotest.tools/v3"
> >>>
> >>> After much painful investigation, I found out that gotest.tools uses
> >>> "import aliases" everywhere. That is, lines such as:
> >>>
> >>>      package assert // import "gotest.tools/v3/assert"
> >>>
> >>> The directive "// import ..." is an import alias, and that's what
> >>> prevents Go from dealing with the import path successfully.
> >>>
> >> That feels awkward... Can we just add a patch to remove this alias?
> >
> > Yep I'm doing exactly that at the moment, and discussing the issue
> > with upstream [1]. It seems like these import aliases are not needed
> > anyway.
> >
> > [1]: https://github.com/gotestyourself/gotest.tools/issues/203
> >
> >
>
> Oh well. So in the end, I tried it, same as with godbus, ie. installing
> gotest.tools v3 at the path `/usr/share/gocode/src/gotest.tools`.
>
> It doesn't work with a number of packages, for example `gotestum`. Ie.
>
>      package gotest.tools/gotestsum (test)
>        imports gotest.tools/assert
>        imports gotest.tools/v3/assert/cmp: cannot find package
> "gotest.tools/v3/assert/cmp" in any of:
>        /usr/lib/go-1.14/src/gotest.tools/v3/assert/cmp (from $GOROOT)
> /<<PKGBUILDDIR>>/_build/src/gotest.tools/v3/assert/cmp (from $GOPATH)
>
> I don't understand what's wrong, I spent a while on this issue, with no
> success.

Because the version of gotestum in debian:
1. have go.mod
2. and declare it wants v2
See https://salsa.debian.org/go-team/packages/gotestsum/-/blob/debian/0.4.0-2/go.mod

It only works when:
1. it has go.mod
2. and declare it wants v3 or don't declare it want any version.

>
> In any case, gotest.tools has little reverse build deps. So I will just
> install it at the path `gotest.tools/v3`, and patch reverse build deps
> as needed. Some of these deps already switched to using v3 upstream already.
>
> Thanks for the support Go team!
>


-- 
Shengjing Zhu


Reply to: