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 2025/04/10 05:21:10 UTC

(opendal) branch bindings-go-doc updated (dea437906 -> aed487b6b)

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

yuchanns pushed a change to branch bindings-go-doc
in repository https://gitbox.apache.org/repos/asf/opendal.git


 discard dea437906 doc(bindings/go): better Linux test script
     new aed487b6b doc(bindings/go): better Linux test script

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (dea437906)
            \
             N -- N -- N   refs/heads/bindings-go-doc (aed487b6b)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 bindings/go/README.md | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)


(opendal) 01/01: doc(bindings/go): better Linux test script

Posted by yu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit aed487b6b84367b39237075cdebf61a352f4ee95
Author: Hanchin Hsieh <me...@yuchanns.xyz>
AuthorDate: Thu Apr 10 13:01:23 2025 +0800

    doc(bindings/go): better Linux test script
    
    Hanchin Hsieh <me...@yuchanns.xyz>
---
 bindings/go/README.md | 65 +++++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 55 insertions(+), 10 deletions(-)

diff --git a/bindings/go/README.md b/bindings/go/README.md
index e71bb6535..1863aa4b4 100644
--- a/bindings/go/README.md
+++ b/bindings/go/README.md
@@ -114,10 +114,10 @@ go test -bench .
 
 <details>
   <summary>
-  A benchmark between [purego+libffi](https://github.com/apache/opendal/commit/bf15cecd5e3be6ecaa7056b5594589c9f4d85673) vs [CGO](https://github.com/apache/opendal/commit/9ef494d6df2e9a13c4e5b9b03bcb36ec30c0a7c0)
+  A benchmark between purego+libffi vs CGO
   </summary>
 
-**purego+libffi** (as `new.txt`)
+[**purego+libffi**](https://github.com/apache/opendal/commit/bf15cecd5e3be6ecaa7056b5594589c9f4d85673) (as `new.txt`)
 ```
 goos: linux
 goarch: arm64
@@ -134,7 +134,7 @@ PASS
 ok
 ```
 
-**CGO** (as `old.txt`)
+[**CGO**](https://github.com/apache/opendal/commit/9ef494d6df2e9a13c4e5b9b03bcb36ec30c0a7c0) (as `old.txt`)
 ```
 go test -bench=. -tags dynamic .
 goos: linux
@@ -209,17 +209,22 @@ geomean          129.7ยต
 
 ## Development
 
-The guide is based on Linux. For other platforms, please adjust the commands accordingly.
+The guide is based on Linux and Windows. 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
+- (Optional for Windows) libffi-8.dll
 
 We use `go workspace` to manage and build the dependencies. To set up the workspace, run the following commands:
 
-**Linux and macOS**
+<details>
+  <summary>
+  **For Linux**
+  </summary>
+
 
 ```bash
 mkdir opendal_workspace
@@ -237,20 +242,56 @@ go work use ./opendal-go-services/memory
 cat <<EOF > ./make_test.sh
 #!/bin/bash
 
+# Check if OPENDAL_TEST is set
+if [ -z "\$OPENDAL_TEST" ]; then
+    echo "Error: OPENDAL_TEST environment variable is not set"
+    echo "Please set OPENDAL_TEST to specify which backend to test (e.g., fs or memory)"
+    exit 1
+fi
+
+# Specify the backend to test
+export SERVICE="\$OPENDAL_TEST"
+
+# Get architecture
 architecture=\$(uname -m)
-if [ "\$architecture" = "x86_64" ]\;\; then
+if [ "\$architecture" = "x86_64" ]; then
     ARCH="x86_64"
-elif [ "\$architecture" = "aarch64" ] || [ "\$architecture" = "arm64" ]\;\; then
+elif [ "\$architecture" = "aarch64" ] || [ "\$architecture" = "arm64" ]; then
     ARCH="arm64"
 else
     ARCH="unknown"
 fi
 
+# Build opendal
 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
 
+# Set environment variables
+export GITHUB_WORKSPACE="\$PWD/opendal-go-services"
+export VERSION="latest"
+export TARGET="linux"
+export DIR="\$GITHUB_WORKSPACE/libopendal_c_\$VERSION_\$SERVICE_\$TARGET"
+
+# Create directory if not exists
+mkdir -p "\$DIR"
+
+export OUTPUT="\$DIR/libopendal_c_\$VERSION_\$SERVICE_\$TARGET.so"
+# Compress with zstd
+zstd -19 opendal/bindings/c/target/debug/libopendal_c.so -o \$OUTPUT
+
+# Generate code
+cd opendal-go-services/internal/generate
+go run generate.go
+cd -
+
+# Delete unnecessary files
+rm -rf \$DIR
+
+# Set environment variables for test
+export MATRIX='{"build": [{"target":"linux", "goos":"linux", "goarch": "amd64"}], "service": ["fs"]}'
+
+# Run tests
 go test ./opendal/bindings/go/tests/behavior_tests -v -run TestBehavior
 EOF
 
@@ -274,11 +315,14 @@ export OPENDAL_FS_ROOT=/tmp/opendal
 cd -
 ```
 
+</details>
+
 <details>
   <summary>
-  For Windows
+  **For Windows**
   </summary>
 
+
 ```powershell
 New-Item -ItemType Directory -Path opendal_workspace
 Set-Location -Path opendal_workspace
@@ -294,7 +338,7 @@ go work use ./opendal-go-services/fs
 go work use ./opendal-go-services/memory
 
 @'
-# Specify the backend to test\;Set-Item -Path Env:SERVICE -Value "$env:OPENDAL_TEST"\;# Get architecture\;$architecture = (Get-WmiObject Win32_OperatingSystem).OSArchitecture\;\;if ($architecture -like "*64*") {\;    $ARCH = "x86_64"\;} else {\;    $ARCH = "unknown" \;}\;\;# Build opendal\;Push-Location opendal/bindings/c\;cargo build\;Pop-Location\;\;# Rename dll file\;Rename-Item opendal/bindings/c/target/debug/opendal_c.dll libopendal_c.dll\;\;# Set environment variables\;Set-Item -Pa [...]
+# Check if OPENDAL_TEST is set\;if (-not $env:OPENDAL_TEST) {\;    Write-Error "OPENDAL_TEST environment variable is not set"\;    Write-Host "Please set OPENDAL_TEST to specify which backend to test (e.g., fs or memory)"\;    exit 1\;}\;# Specify the backend to test\;Set-Item -Path Env:SERVICE -Value "$env:OPENDAL_TEST"\;# Get architecture\;$architecture = (Get-WmiObject Win32_OperatingSystem).OSArchitecture\;\;if ($architecture -like "*64*") {\;    $ARCH = "x86_64"\;} else {\;    $ARCH [...]
 '@ -replace "\\;","`n" | Out-File -FilePath "MakeTest.ps1" -Encoding UTF8
 
 Pop-Location
@@ -313,6 +357,7 @@ $env:OPENDAL_FS_ROOT = $env:TEMP
 
 Pop-Location
 ```
+
 </details>
 
 ## License and Trademarks