On Mon, Oct 25, 2021 at 05:22:28PM +0300, Nir Soffer wrote:
> On Mon, Oct 25, 2021 at 5:01 PM Richard W.M. Jones <[email protected]> wrote:
> >
> > [Adding Matthew]
> >
> > On Mon, Oct 25, 2021 at 04:45:03PM +0300, Nir Soffer wrote:
> > > I'm playing with libnbd go module, planning to use it in a new command[1]
> > >
> > > The biggest obstacle for me is that the module is not published in a way 
> > > that
> > > Go developers expect.
> > >
> > > The module is listed in:
> > > https://pkg.go.dev/github.com/libguestfs/libnbd/golang
> > >
> > > But the module actually lives in:
> > > https://github.com/libguestfs/libnbd/tree/master/golang/src/libguestfs.org/libnbd
> > >
> > > So the pkg.go.dev page is broken, .e.g no there is no documation or 
> > > license, and
> > > the suggested import is wrong.
> > >
> > > The module name is "libguestfs.org/libnbd". But if you try to use it,
> > > for example
> > > in the (improved) example from libnbd-golang.pod:
> > >
> > > $ cat test.go
> > > package main
> > >
> > > import "fmt"
> > > import "libguestfs.org/libnbd"
> > >
> > > func main() {
> > >     h, err := libnbd.Create()
> > >     if err != nil {
> > >         panic(err)
> > >     }
> > >     defer h.Close()
> > >     uri := "nbd://localhost"
> > >     err = h.ConnectUri(uri)
> > >     if err != nil {
> > >         panic(err)
> > >     }
> > >     size, err := h.GetSize()
> > >     if err != nil {
> > >         panic(err)
> > >     }
> > >     fmt.Printf("size of %s = %d\n", uri, size)
> > > }
> > >
> > > $ go mod init example/test
> > > go: creating new go.mod: module example/test
> > > go: to add module requirements and sums:
> > >         go mod tidy
> > >
> > > $ go mod tidy
> > > go: finding module for package libguestfs.org/libnbd
> > > example/test imports
> > >         libguestfs.org/libnbd: cannot find module providing package
> > > libguestfs.org/libnbd: unrecognized import path
> > > "libguestfs.org/libnbd": reading
> > > https://libguestfs.org/libnbd?go-get=1: 404 Not Found
> >
> > That website is entirely static so if it involves fetching stuff from
> > there it's probably not going to work.
> 
> So the import path should be:
> 
>     gitlab.com/libnbd/golang/src/libguestfs.org/libnbd
> 
> Since gitlab (or github) already supports go tools.

Depends if you want applications to be susceptible to future changes
in where the code is located. A libguestfs.org/libnbd import would
mean you can move git hosting without impacting apps.

It is fairly simple to configure - you just need the web address

  https://libguestfs.org/libnbd

to serve up an HTML document that contains a magic <meta> tag in
the page header

    <meta name="go-import" content="libguestfs.org/libnbd git 
https://gitlab.com/path/to/real/git/repo/location"/>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

_______________________________________________
Libguestfs mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/libguestfs

Reply via email to