Fix go_sample.sh (#7903)
This commit is contained in:
parent
52f2596e15
commit
fa3fa91936
|
@ -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
|
|
@ -41,23 +41,18 @@ fi
|
||||||
|
|
||||||
echo Compiling and running the Go sample.
|
echo Compiling and running the Go sample.
|
||||||
|
|
||||||
# Go requires a particular layout of files in order to link the necessary
|
# Workaround for https://github.com/google/flatbuffers/issues/7780:
|
||||||
# packages. Copy these files to the respective directores to compile the
|
# go mod replace requires a go.mod file in the target directory,
|
||||||
# sample.
|
# but there currently isn't one in the ../go directory.
|
||||||
mkdir -p ${sampledir}/go_gen/src/MyGame/Sample
|
# So we copy the ../go directory to go_gen and manually create go_gen/go.mod
|
||||||
mkdir -p ${sampledir}/go_gen/src/github.com/google/flatbuffers/go
|
mkdir -p ${sampledir}/go_gen
|
||||||
cp MyGame/Sample/*.go ${sampledir}/go_gen/src/MyGame/Sample/
|
cp ${sampledir}/../go/* ${sampledir}/go_gen
|
||||||
cp ${sampledir}/../go/* ${sampledir}/go_gen/src/github.com/google/flatbuffers/go
|
( cd ${sampledir}/go_gen && go mod init 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/
|
|
||||||
|
|
||||||
# Compile and execute the sample.
|
# Compile and execute the sample.
|
||||||
go build -o go_sample sample_binary.go
|
go build -o go_sample sample_binary.go
|
||||||
./go_sample
|
./go_sample
|
||||||
|
|
||||||
# Clean up the temporary files.
|
# Clean up the temporary files.
|
||||||
rm -rf MyGame/
|
|
||||||
rm -rf ${sampledir}/go_gen/
|
rm -rf ${sampledir}/go_gen/
|
||||||
rm go_sample
|
rm go_sample
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
sample "MyGame/Sample"
|
sample "github.com/google/flatbuffers/samples/MyGame/Sample"
|
||||||
"fmt"
|
"fmt"
|
||||||
flatbuffers "github.com/google/flatbuffers/go"
|
flatbuffers "github.com/google/flatbuffers/go"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
Loading…
Reference in New Issue