Richard W.M. Jones
2021-Apr-01 14:31 UTC
[Libguestfs] [PATCH nbdkit] golang: Add go.mod files, remove use of $GOPATH.
golang 1.16 defaults to this, and 1.17 will require it: https://blog.golang.org/go116-module-changes Fixes: https://aur.archlinux.org/packages/nbdkit/ Thanks: Svenne Krap --- plugins/golang/Makefile.am | 9 +++++---- plugins/golang/examples/disk/go.mod | 4 ++++ plugins/golang/examples/dump-plugin/go.mod | 4 ++++ plugins/golang/examples/minimal/go.mod | 4 ++++ plugins/golang/examples/ramdisk/go.mod | 4 ++++ plugins/golang/src/libguestfs.org/nbdkit/go.mod | 4 ++++ 6 files changed, 25 insertions(+), 4 deletions(-) diff --git a/plugins/golang/Makefile.am b/plugins/golang/Makefile.am index 192c2ec4..6fc4f8b4 100644 --- a/plugins/golang/Makefile.am +++ b/plugins/golang/Makefile.am @@ -32,6 +32,7 @@ include $(top_srcdir)/common-rules.mk plugin_sources = \ + src/libguestfs.org/nbdkit/go.mod \ src/libguestfs.org/nbdkit/nbdkit.go \ src/libguestfs.org/nbdkit/utils.go \ src/libguestfs.org/nbdkit/wrappers.go \ @@ -43,9 +44,13 @@ EXTRA_DIST = \ config-test.go \ dump-plugin-examples.sh \ examples/disk/disk.go \ + examples/disk/go.mod \ examples/dump-plugin/dumpplugin.go \ + examples/dump-plugin/go.mod \ examples/minimal/minimal.go \ + examples/minimal/go.mod \ examples/ramdisk/ramdisk.go \ + examples/ramdisk/go.mod \ nbdkit-golang-plugin.pod \ $(NULL) @@ -67,28 +72,24 @@ examples/disk/nbdkit-godisk-plugin.so: \ $(plugin_sources) examples/disk/disk.go cd examples/disk && \ PKG_CONFIG_PATH="$(abs_top_builddir)/server/local$${PKG_CONFIG_PATH:+:$$PKG_CONFIG_PATH}" \ - GOPATH="$(abs_builddir)" \ $(GOLANG) build -o nbdkit-godisk-plugin.so -buildmode=c-shared examples/dump-plugin/nbdkit-godump-plugin.so: \ $(plugin_sources) examples/dump-plugin/dumpplugin.go cd examples/dump-plugin && \ PKG_CONFIG_PATH="$(abs_top_builddir)/server/local$${PKG_CONFIG_PATH:+:$$PKG_CONFIG_PATH}" \ - GOPATH="$(abs_builddir)" \ $(GOLANG) build -o nbdkit-godump-plugin.so -buildmode=c-shared examples/minimal/nbdkit-gominimal-plugin.so: \ $(plugin_sources) examples/minimal/minimal.go cd examples/minimal && \ PKG_CONFIG_PATH="$(abs_top_builddir)/server/local$${PKG_CONFIG_PATH:+:$$PKG_CONFIG_PATH}" \ - GOPATH="$(abs_builddir)" \ $(GOLANG) build -o nbdkit-gominimal-plugin.so -buildmode=c-shared examples/ramdisk/nbdkit-goramdisk-plugin.so: \ $(plugin_sources) examples/ramdisk/ramdisk.go cd examples/ramdisk && \ PKG_CONFIG_PATH="$(abs_top_builddir)/server/local$${PKG_CONFIG_PATH:+:$$PKG_CONFIG_PATH}" \ - GOPATH="$(abs_builddir)" \ $(GOLANG) build -o nbdkit-goramdisk-plugin.so -buildmode=c-shared # Tests. diff --git a/plugins/golang/examples/disk/go.mod b/plugins/golang/examples/disk/go.mod new file mode 100644 index 00000000..b55533c8 --- /dev/null +++ b/plugins/golang/examples/disk/go.mod @@ -0,0 +1,4 @@ +module main + +replace libguestfs.org/nbdkit => ../../src/libguestfs.org/nbdkit +require libguestfs.org/nbdkit v1.0.0 diff --git a/plugins/golang/examples/dump-plugin/go.mod b/plugins/golang/examples/dump-plugin/go.mod new file mode 100644 index 00000000..b55533c8 --- /dev/null +++ b/plugins/golang/examples/dump-plugin/go.mod @@ -0,0 +1,4 @@ +module main + +replace libguestfs.org/nbdkit => ../../src/libguestfs.org/nbdkit +require libguestfs.org/nbdkit v1.0.0 diff --git a/plugins/golang/examples/minimal/go.mod b/plugins/golang/examples/minimal/go.mod new file mode 100644 index 00000000..b55533c8 --- /dev/null +++ b/plugins/golang/examples/minimal/go.mod @@ -0,0 +1,4 @@ +module main + +replace libguestfs.org/nbdkit => ../../src/libguestfs.org/nbdkit +require libguestfs.org/nbdkit v1.0.0 diff --git a/plugins/golang/examples/ramdisk/go.mod b/plugins/golang/examples/ramdisk/go.mod new file mode 100644 index 00000000..b55533c8 --- /dev/null +++ b/plugins/golang/examples/ramdisk/go.mod @@ -0,0 +1,4 @@ +module main + +replace libguestfs.org/nbdkit => ../../src/libguestfs.org/nbdkit +require libguestfs.org/nbdkit v1.0.0 diff --git a/plugins/golang/src/libguestfs.org/nbdkit/go.mod b/plugins/golang/src/libguestfs.org/nbdkit/go.mod new file mode 100644 index 00000000..6ba51bd5 --- /dev/null +++ b/plugins/golang/src/libguestfs.org/nbdkit/go.mod @@ -0,0 +1,4 @@ +module libguestfs.org/nbdkit + +// First version of golang with working module support. +go 1.13 -- 2.29.0.rc2
Daniel P. Berrangé
2021-Apr-01 14:38 UTC
[Libguestfs] [PATCH nbdkit] golang: Add go.mod files, remove use of $GOPATH.
On Thu, Apr 01, 2021 at 03:31:35PM +0100, Richard W.M. Jones wrote:> golang 1.16 defaults to this, and 1.17 will require it: > https://blog.golang.org/go116-module-changes > > Fixes: https://aur.archlinux.org/packages/nbdkit/ > Thanks: Svenne Krap > --- > plugins/golang/Makefile.am | 9 +++++---- > plugins/golang/examples/disk/go.mod | 4 ++++ > plugins/golang/examples/dump-plugin/go.mod | 4 ++++ > plugins/golang/examples/minimal/go.mod | 4 ++++ > plugins/golang/examples/ramdisk/go.mod | 4 ++++ > plugins/golang/src/libguestfs.org/nbdkit/go.mod | 4 ++++ > 6 files changed, 25 insertions(+), 4 deletions(-)> diff --git a/plugins/golang/examples/disk/go.mod b/plugins/golang/examples/disk/go.mod > new file mode 100644 > index 00000000..b55533c8 > --- /dev/null > +++ b/plugins/golang/examples/disk/go.mod > @@ -0,0 +1,4 @@ > +module main > + > +replace libguestfs.org/nbdkit => ../../src/libguestfs.org/nbdkit > +require libguestfs.org/nbdkit v1.0.0This is needed because the nbdkit opackage is in a different part of the directory subtree from this dir. If desired, you can avoid needing these per-example go.mod files by moving the src/libguestfs.org/nbdkit files into a direct ancestor directory of the examples. Either approach works though, and neither is inherantly bad or wrong, so pick your favourite, and on that basis Reviewed-by: Daniel P. Berrang? <berrange at redhat.com> 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 :|