diff options
author | Jeroen Demeyer <jeroen.k.demeyer@gmail.com> | 2023-04-11 21:40:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-11 12:40:00 -0700 |
commit | fa3fa91936fe42a1d687c332c7b84412a21f64a6 (patch) | |
tree | e674a083e62119cf5646d8f2f4dc5f9a896a66c5 | |
parent | 52f2596e1568dc2ace313bde6a63bc1ee2d7f0bb (diff) | |
download | flatbuffers-fa3fa91936fe42a1d687c332c7b84412a21f64a6.tar.gz flatbuffers-fa3fa91936fe42a1d687c332c7b84412a21f64a6.tar.bz2 flatbuffers-fa3fa91936fe42a1d687c332c7b84412a21f64a6.zip |
Fix go_sample.sh (#7903)
-rw-r--r-- | samples/go.mod | 7 | ||||
-rwxr-xr-x | samples/go_sample.sh | 19 | ||||
-rw-r--r-- | samples/sample_binary.go | 2 |
3 files changed, 15 insertions, 13 deletions
diff --git a/samples/go.mod b/samples/go.mod new file mode 100644 index 00000000..c8f892b8 --- /dev/null +++ b/samples/go.mod @@ -0,0 +1,7 @@ +module github.com/google/flatbuffers/samples + +go 1.20 + +replace github.com/google/flatbuffers/go => ./go_gen + +require github.com/google/flatbuffers/go v0.0.0-00010101000000-000000000000 diff --git a/samples/go_sample.sh b/samples/go_sample.sh index 13a96c12..9ccd48ed 100755 --- a/samples/go_sample.sh +++ b/samples/go_sample.sh @@ -41,23 +41,18 @@ fi echo Compiling and running the Go sample. -# Go requires a particular layout of files in order to link the necessary -# packages. Copy these files to the respective directores to compile the -# sample. -mkdir -p ${sampledir}/go_gen/src/MyGame/Sample -mkdir -p ${sampledir}/go_gen/src/github.com/google/flatbuffers/go -cp MyGame/Sample/*.go ${sampledir}/go_gen/src/MyGame/Sample/ -cp ${sampledir}/../go/* ${sampledir}/go_gen/src/github.com/google/flatbuffers/go - -# Export the `GOPATH`, so that `go` will know which directories to search for -# the libraries. -export GOPATH=${sampledir}/go_gen/ +# Workaround for https://github.com/google/flatbuffers/issues/7780: +# go mod replace requires a go.mod file in the target directory, +# but there currently isn't one in the ../go directory. +# So we copy the ../go directory to go_gen and manually create go_gen/go.mod +mkdir -p ${sampledir}/go_gen +cp ${sampledir}/../go/* ${sampledir}/go_gen +( cd ${sampledir}/go_gen && go mod init github.com/google/flatbuffers/go ) # Compile and execute the sample. go build -o go_sample sample_binary.go ./go_sample # Clean up the temporary files. -rm -rf MyGame/ rm -rf ${sampledir}/go_gen/ rm go_sample diff --git a/samples/sample_binary.go b/samples/sample_binary.go index e04650be..7b7efac2 100644 --- a/samples/sample_binary.go +++ b/samples/sample_binary.go @@ -19,7 +19,7 @@ package main import ( - sample "MyGame/Sample" + sample "github.com/google/flatbuffers/samples/MyGame/Sample" "fmt" flatbuffers "github.com/google/flatbuffers/go" "strconv" |