Move the configure test module to configure/test.go, and create new
module for this directory, so it does not clash with the real libnbd
module, that I want to move up to the golang/ directory.
Instead of running "go version", print runtime.Version() in the test
program.
$ go run golang/configure/test.go
go1.16.8
Instead of running "go help modules" for checking if modules are
supported, using "go mod tidy". This will fail if the installed go
version is to old, since the go.mod file specify go 1.13, like the real
libnbd go.mod.
$ (cd golang/configure/ && go mod tidy)
go mod tidy: go.mod file indicates go 1.17, but maximum supported version is 1.16
I did not try to verify the go version, since it seems impossible given
the crazy versioning. However if we want to verify the version we can do
this using the test output outside of go.
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
configure.ac | 10 +++++-----
golang/Makefile.am | 3 ++-
golang/configure/go.mod | 4 ++++
golang/{config-test.go => configure/test.go} | 7 +++++++
4 files changed, 18 insertions(+), 6 deletions(-)
create mode 100644 golang/configure/go.mod
rename golang/{config-test.go => configure/test.go} (95%)
diff --git a/configure.ac b/configure.ac
index 82ac5ea..e1a0198 100644
--- a/configure.ac
+++ b/configure.ac
@@ -508,12 +508,12 @@ AS_IF([test "x$enable_golang" != "xno"],[
AC_CHECK_PROG([GOLANG],[go],[go],[no])
AS_IF([test "x$GOLANG" != "xno"],[
AC_MSG_CHECKING([if $GOLANG is usable])
- AS_IF([ $GOLANG run $srcdir/golang/config-test.go 2>&AS_MESSAGE_LOG_FD
&& \
- $GOLANG help modules 2>&AS_MESSAGE_LOG_FD 1>&2 ],[
+ AS_IF([ (
+ cd $srcdir/golang/configure
+ $GOLANG run . 2>&AS_MESSAGE_LOG_FD 1>&2
+ $GOLANG mod tidy 2>&AS_MESSAGE_LOG_FD 1>&2
+ ) ],[
AC_MSG_RESULT([yes])
-
- # Print the version to help with debugging.
- $GOLANG version
],[
AC_MSG_RESULT([no])
AC_MSG_WARN([golang ($GOLANG) is installed but not usable])
diff --git a/golang/Makefile.am b/golang/Makefile.am
index 93089e2..397cae7 100644
--- a/golang/Makefile.am
+++ b/golang/Makefile.am
@@ -58,7 +58,8 @@ generator_built = \
EXTRA_DIST = \
$(generator_built) \
- config-test.go \
+ configure/go.mod \
+ configure/test.go \
libnbd-golang.pod \
run-tests.sh \
src/$(pkg)/.gitignore \
diff --git a/golang/configure/go.mod b/golang/configure/go.mod
new file mode 100644
index 0000000..ce3e4f3
--- /dev/null
+++ b/golang/configure/go.mod
@@ -0,0 +1,4 @@
+module
libguestfs.org/configure
+
+// First version of golang with working module support.
+go 1.13
diff --git a/golang/config-test.go b/golang/configure/test.go
similarity index 95%
rename from golang/config-test.go
rename to golang/configure/test.go
index e104c71..53ce8ab 100644
--- a/golang/config-test.go
+++ b/golang/configure/test.go
@@ -22,7 +22,14 @@
package main
+import (
+ "fmt"
+ "runtime"
+)
+
func main() {
+ fmt.Println(runtime.Version())
+
/* XXX Check for minimum runtime.Version() >= "go1.1.1"
* Unfortunately go version numbers are not easy to parse.
* They have the 3 formats "goX.Y.Z", "release.rN" or
--
2.31.1