This is an automated email from the ASF dual-hosted git repository.

yuchanns pushed a commit to branch dev-for-go-binding
in repository https://gitbox.apache.org/repos/asf/opendal.git


The following commit(s) were added to refs/heads/dev-for-go-binding by this 
push:
     new c7793ee069 docs(bindings/go): add development guide
c7793ee069 is described below

commit c7793ee0691f586cfaf9ae434e44ae0a2f03b0e4
Author: Hanchin Hsieh <[email protected]>
AuthorDate: Mon Oct 14 15:05:52 2024 +0800

    docs(bindings/go): add development guide
    
    Signed-off-by: Hanchin Hsieh <[email protected]>
---
 bindings/go/README.md | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/bindings/go/README.md b/bindings/go/README.md
index bcbb68f161..3aaf383a80 100644
--- a/bindings/go/README.md
+++ b/bindings/go/README.md
@@ -208,6 +208,65 @@ geomean          129.7ยต
 - [x] Copy
 - [x] Rename
 
+## Development
+
+The guid 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 [email protected]:apache/opendal.git
+git clone [email protected]:apache/opendal-go-services.git
+
+go workspace init
+go workspace use ./opendal/bindings/go
+go workspace use ./opendal/bindings/go/tests/behavior_tests
+go workspace use ./opendal-go-services/fs
+go workspace use ./opendal-go-services/memory
+
+cat <<EOF > ./build.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
+EOF
+
+chmod +x ./build.sh
+```
+
+To build and run tests, run the following commands:
+
+```bash
+cd opendal_workspace
+
+# Build the C binding
+./build.sh
+
+# specify the backend to test
+export OPENDAL_TEST=fs
+export OPENDAL_FS_ROOT=/tmp/opendal
+
+go test ./opendal/bindings/go/tests/behavior_tests -v -run TestBehavior
+```
 
 ## License and Trademarks
 

Reply via email to