mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-26 02:52:40 +00:00
Fix go_sample.sh (#7903)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user