From f40a34c04b923d6f04bf46f02266b2dd86a612ab Mon Sep 17 00:00:00 2001 From: Darren Cheng <1912544842@qq.com> Date: Fri, 1 Mar 2024 12:33:38 +0800 Subject: [PATCH] add go support (#59) --- .github/workflows/ci.yml | 24 +++++++++++++++++++++++ README.md | 40 +++++++++++++++++++++++++++++++++++++++ go/go.mod | 3 +++ go/main.go | 15 +++++++++++++++ go/ruapu/ruapu-binding.go | 36 +++++++++++++++++++++++++++++++++++ 5 files changed, 118 insertions(+) create mode 100644 go/go.mod create mode 100644 go/main.go create mode 100644 go/ruapu/ruapu-binding.go diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 372bce8..ac0c709 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,6 +55,12 @@ jobs: cd erlang rebar3 compile rebar3 eunit + - name: build-test-golang + run: | + cd go + go build -o ruapu-go + ./ruapu-go + macos: runs-on: macos-latest @@ -79,6 +85,11 @@ jobs: cd rust cargo build --verbose cargo test --verbose + - name: build-test-golang + run: | + cd go + go build -o ruapu-go + ./ruapu-go macos-arm64: runs-on: macos-14 @@ -103,6 +114,14 @@ jobs: cd rust cargo build --verbose cargo test --verbose + - uses: actions/setup-go@v2 + with: + go-version: 1.21.x + - name: build-test-golang + run: | + cd go + go build -o ruapu-go + ./ruapu-go windows: runs-on: windows-latest @@ -142,6 +161,11 @@ jobs: cd erlang rebar3 compile rebar3 eunit + - name: build-test-golang + run: | + cd go + go build -o ruapu-go.exe + ./ruapu-go.exe qemu: runs-on: ubuntu-latest diff --git a/README.md b/README.md index 993cac8..be36c1a 100644 --- a/README.md +++ b/README.md @@ -264,6 +264,46 @@ end program main +### ruapu with Golang + +
+ +Compile ruapu library + +```shell +cd go +go build -o ruapu-go +``` + + | ++ +Use ruapu in Golang + +```go +package main + +import ( + "fmt" + "ruapu-go/ruapu" + "strconv" +) + +func main() { + ruapu.Init() + avx2Status := ruapu.Supports("avx2") + fmt.Println("avx2:" + strconv.Itoa(avx2Status)) + rua := ruapu.Rua() + fmt.Println(rua) +} +``` + + |