You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by yu...@apache.org on 2024/10/14 07:25:04 UTC

(opendal) 01/01: docs(bindings/go): add development guide

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

commit a413e52e90a5985595d2d7152a8867c3d5802f62
Author: Hanchin Hsieh <me...@yuchanns.xyz>
AuthorDate: Mon Oct 14 15:05:52 2024 +0800

    docs(bindings/go): add development guide
    
    Signed-off-by: Hanchin Hsieh <me...@yuchanns.xyz>
---
 bindings/go/README.md | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)

diff --git a/bindings/go/README.md b/bindings/go/README.md
index bcbb68f161..7cf8e9d359 100644
--- a/bindings/go/README.md
+++ b/bindings/go/README.md
@@ -208,6 +208,70 @@ 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 --depth 1 git@github.com:apache/opendal.git
+git clone --depth 1 git@github.com: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