Skip to content

Commit

Permalink
Add contributing docs for Golang (#5179)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
yuchanns authored Oct 14, 2024
1 parent 5dbe6fe commit a225b19
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci_bindings_go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
64 changes: 64 additions & 0 deletions bindings/go/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 0 additions & 6 deletions bindings/go/tests/go.work

This file was deleted.

2 changes: 0 additions & 2 deletions bindings/go/tests/go.work.sum

This file was deleted.

0 comments on commit a225b19

Please sign in to comment.