This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opendal.git
The following commit(s) were added to refs/heads/main by this push:
new a225b19992 Add contributing docs for Golang (#5179)
a225b19992 is described below
commit a225b19992befd2a092ce74c7ff8533ff97ab22e
Author: Hanchin Hsieh <[email protected]>
AuthorDate: Mon Oct 14 16:03:23 2024 +0800
Add contributing docs for Golang (#5179)
* ci(bindings/go): remove preset go workspace
Signed-off-by: Hanchin Hsieh <[email protected]>
* docs(bindings/go): add development guide
Signed-off-by: Hanchin Hsieh <[email protected]>
* docs(bindings/go): fix typo
Signed-off-by: Hanchin Hsieh <[email protected]>
---------
Signed-off-by: Hanchin Hsieh <[email protected]>
---
.github/workflows/ci_bindings_go.yml | 3 ++
bindings/go/README.md | 64 ++++++++++++++++++++++++++++++++++++
bindings/go/tests/go.work | 6 ----
bindings/go/tests/go.work.sum | 2 --
4 files changed, 67 insertions(+), 8 deletions(-)
diff --git a/.github/workflows/ci_bindings_go.yml
b/.github/workflows/ci_bindings_go.yml
index 5ffd5dca56..e4c4df7365 100644
--- a/.github/workflows/ci_bindings_go.yml
+++ b/.github/workflows/ci_bindings_go.yml
@@ -123,6 +123,9 @@ jobs:
SERVICE: ${{ matrix.service }}
working-directory: bindings/go/tests
run: |
+ go work init
+ go work use ..
+ go work use ./behavior_tests
go work use $GITHUB_WORKSPACE/$(echo $SERVICE | sed 's/-/_/g')
- name: Run tests
env:
diff --git a/bindings/go/README.md b/bindings/go/README.md
index bcbb68f161..3b6cd166e0 100644
--- a/bindings/go/README.md
+++ b/bindings/go/README.md
@@ -208,6 +208,70 @@ geomean 129.7ยต
- [x] Copy
- [x] Rename
+## Development
+
+The guide is based on Linux. For other platforms, please adjust the commands
accordingly.
+
+To develop the Go binding, you need to have the following dependencies
installed:
+
+- zstd
+- Rust toolchain
+- Go
+
+We use `go workspace` to manage and build the dependencies. To set up the
workspace, run the following commands:
+
+```bash
+mkdir opendal_workspace
+cd opendal_workspace
+git clone --depth 1 [email protected]:apache/opendal.git
+git clone --depth 1 [email protected]:apache/opendal-go-services.git
+
+go work init
+go work use ./opendal/bindings/go
+go work use ./opendal/bindings/go/tests/behavior_tests
+# use the backend you want to test, e.g., fs or memory
+go work use ./opendal-go-services/fs
+go work use ./opendal-go-services/memory
+
+cat <<EOF > ./make_test.sh
+#!/bin/bash
+
+architecture=\$(uname -m)
+if [ "\$architecture" = "x86_64" ]; then
+ ARCH="x86_64"
+elif [ "\$architecture" = "aarch64" ] || [ "\$architecture" = "arm64" ]; then
+ ARCH="arm64"
+else
+ ARCH="unknown"
+fi
+
+cd opendal/bindings/c
+cargo build
+cd -
+zstd -19 opendal/bindings/c/target/debug/libopendal_c.so -o
opendal-go-services/fs/libopendal_c.linux.\$ARCH.so.zst
+
+go test ./opendal/bindings/go/tests/behavior_tests -v -run TestBehavior
+EOF
+
+chmod +x ./make_test.sh
+
+cd -
+```
+
+To build and run tests, run the following commands:
+
+```bash
+cd opendal_workspace
+
+# specify the backend to test
+export OPENDAL_TEST=fs
+export OPENDAL_FS_ROOT=/tmp/opendal
+
+# build the C binding and run the tests
+./make_test.sh
+
+cd -
+```
## License and Trademarks
diff --git a/bindings/go/tests/go.work b/bindings/go/tests/go.work
deleted file mode 100644
index dc66d28856..0000000000
--- a/bindings/go/tests/go.work
+++ /dev/null
@@ -1,6 +0,0 @@
-go 1.22.5
-
-use (
- ..
- ./behavior_tests
-)
diff --git a/bindings/go/tests/go.work.sum b/bindings/go/tests/go.work.sum
deleted file mode 100644
index 93e5f73a8e..0000000000
--- a/bindings/go/tests/go.work.sum
+++ /dev/null
@@ -1,2 +0,0 @@
-github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
-github.com/stretchr/objx v0.5.2/go.mod
h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=