golang: Fix bindings for golang 1.16.

See https://blog.golang.org/go116-module-changes
This commit is contained in:
Richard W.M. Jones
2021-04-08 12:03:39 +01:00
parent 0f54df53d2
commit 95de3f6c50
14 changed files with 36 additions and 35 deletions

3
.gitignore vendored
View File

@@ -211,10 +211,9 @@ Makefile.in
/gobject/guestfs-gobject.3
/gobject/libguestfs-gobject-1.0.vapi
/gobject/stamp-guestfs-gobject.pod
/golang/bindtests.go
/golang/bindtests/bindtests.go
/golang/examples/guestfs-golang.3
/golang/examples/stamp-guestfs-golang.pod
/golang/pkg
/haskell/Bindtests
/haskell/Bindtests.hs
/haskell/Guestfs010Load

View File

@@ -301,7 +301,7 @@ Run it from the top source directory using the command
output_to "golang/src/libguestfs.org/guestfs/guestfs.go"
Golang.generate_golang_go;
output_to "golang/bindtests.go"
output_to "golang/bindtests/bindtests.go"
Bindtests.generate_golang_bindtests;
output_to "gobject/bindtests.js"

View File

@@ -26,27 +26,20 @@ source_files = \
generator_built = \
$(source_files) \
bindtests.go
bindtests/bindtests.go
EXTRA_DIST = \
src/libguestfs.org/guestfs/.gitignore \
$(generator_built) \
bindtests/go.mod \
config-test.go \
run-bindtests \
run-tests
if HAVE_GOLANG
golangpkgdir = $(GOROOT)/pkg/$(GOOS)_$(GOARCH)/$(pkg)
golangsrcdir = $(GOROOT)/src/pkg/$(pkg)
golangpkg_DATA = \
pkg/$(GOOS)_$(GOARCH)/$(pkg).a
pkg/$(GOOS)_$(GOARCH)/$(pkg).a: src/$(pkg)/guestfs.go
$(top_builddir)/run $(GOLANG) install $(pkg)
golangsrc_DATA = $(source_files)
all-local: $(source_files)
cd src/$(pkg) && $(GOLANG) build
TESTS_ENVIRONMENT = pkg=$(pkg) $(top_builddir)/run $(VG) # --test
@@ -55,6 +48,3 @@ TESTS = run-bindtests run-tests
endif
CLEANFILES += src/$(pkg)/*~
clean-local:
rm -rf pkg

4
golang/bindtests/go.mod Normal file
View File

@@ -0,0 +1,4 @@
module main
replace libguestfs.org/guestfs => ../src/libguestfs.org/guestfs
require libguestfs.org/guestfs v1.0.0

View File

@@ -19,8 +19,10 @@ include $(top_srcdir)/subdir-rules.mk
EXTRA_DIST = \
LICENSE \
create-disk.go \
inspect-vm.go \
create-disk/go.mod \
create-disk/create-disk.go \
inspect-vm/go.mod \
inspect-vm/inspect-vm.go \
guestfs-golang.pod
man_MANS = guestfs-golang.3
@@ -28,13 +30,14 @@ noinst_DATA = $(top_builddir)/website/guestfs-golang.3.html
guestfs-golang.3 $(top_builddir)/website/guestfs-golang.3.html: stamp-guestfs-golang.pod
stamp-guestfs-golang.pod: guestfs-golang.pod create-disk.go inspect-vm.go
stamp-guestfs-golang.pod: guestfs-golang.pod \
create-disk/create-disk.go inspect-vm/inspect-vm.go
$(PODWRAPPER) \
--section 3 \
--man guestfs-golang.3 \
--html $(top_builddir)/website/guestfs-golang.3.html \
--verbatim $(srcdir)/create-disk.go:@EXAMPLE1@ \
--verbatim $(srcdir)/inspect-vm.go:@EXAMPLE2@ \
--verbatim $(srcdir)/create-disk/create-disk.go:@EXAMPLE1@ \
--verbatim $(srcdir)/inspect-vm/inspect-vm.go:@EXAMPLE2@ \
--license examples \
$<
touch $@

View File

@@ -0,0 +1,4 @@
module main
replace libguestfs.org/guestfs => ../../src/libguestfs.org/guestfs
require libguestfs.org/guestfs v1.0.0

View File

@@ -0,0 +1,4 @@
module main
replace libguestfs.org/guestfs => ../../src/libguestfs.org/guestfs
require libguestfs.org/guestfs v1.0.0

View File

@@ -18,6 +18,7 @@
set -e
$GOLANG run $srcdir/bindtests.go > bindtests.tmp
diff -u $srcdir/../bindtests bindtests.tmp
cd $srcdir/bindtests
$GOLANG run bindtests.go > bindtests.tmp
diff -u $srcdir/../../bindtests bindtests.tmp
rm bindtests.tmp

View File

@@ -18,4 +18,6 @@
set -e
$GOLANG test $pkg
cd src/$pkg
$GOLANG test

View File

@@ -0,0 +1,4 @@
module libguestfs.org/guestfs
// First version of golang with working module support.
go 1.13

View File

@@ -26,14 +26,6 @@ AS_IF([test "x$enable_golang" != "xno"],[
AC_MSG_CHECKING([if $GOLANG is usable])
AS_IF([$GOLANG run $srcdir/golang/config-test.go 2>&AS_MESSAGE_LOG_FD],[
AC_MSG_RESULT([yes])
# Substitute some golang environment.
GOOS=`$GOLANG env GOOS`
GOARCH=`$GOLANG env GOARCH`
GOROOT=`$GOLANG env GOROOT`
AC_SUBST([GOOS])
AC_SUBST([GOARCH])
AC_SUBST([GOROOT])
],[
AC_MSG_RESULT([no])
AC_MSG_WARN([golang ($GOLANG) is installed but not usable])

2
run.in
View File

@@ -178,8 +178,6 @@ export LUA_CPATH
# For golang.
export GOLANG="@GOLANG@"
prepend GOPATH "$b/golang"
export GOPATH
if [ -z "$CGO_CFLAGS" ]; then
CGO_CFLAGS="-I$s/include"
else