From 02e1c552e6d1ac504a30e73f31fd09c1ed43c2f3 Mon Sep 17 00:00:00 2001 From: auxten Date: Sat, 25 May 2024 16:20:55 +0800 Subject: [PATCH] Add go install --- .github/workflows/chdb.yml | 2 +- .github/workflows/release.yml | 2 +- Makefile | 4 ++-- README.md | 18 +++++++++++++----- chdbstable/chdb.go | 2 +- go.mod | 2 +- 6 files changed, 19 insertions(+), 11 deletions(-) diff --git a/.github/workflows/chdb.yml b/.github/workflows/chdb.yml index 629dfd4..1b177fc 100644 --- a/.github/workflows/chdb.yml +++ b/.github/workflows/chdb.yml @@ -25,7 +25,7 @@ jobs: - name: Test run: make test - name: Test main - run: LD_LIBRARY_PATH=./ ./chdb-go "SELECT 12345" + run: ./chdb-go "SELECT 12345" build_mac: runs-on: macos-12 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 11fe621..8da9cb7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,7 +21,7 @@ jobs: go mod tidy make build - name: Test - run: LD_LIBRARY_PATH=. ./chdb-go "SELECT 12345" + run: ./chdb-go "SELECT 12345" - name: Get Version run: | echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV diff --git a/Makefile b/Makefile index 7153c0e..be53ad7 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ update_libchdb: ./update_libchdb.sh install: - curl -sL https://lib.chdb.io | sudo bash + curl -sL https://lib.chdb.io | bash test: CGO_ENABLED=1 go test -v -coverprofile=coverage.out ./... @@ -13,4 +13,4 @@ run: CGO_ENABLED=1 go run main.go build: - CGO_ENABLED=1 go build -o chdb-go main.go + CGO_ENABLED=1 go build -ldflags '-extldflags "-Wl,-rpath,/usr/local/lib"' -o chdb-go main.go diff --git a/README.md b/README.md index 77df377..3570958 100644 --- a/README.md +++ b/README.md @@ -9,12 +9,20 @@ ## Install -1. Download and install [`libchdb`](https://github.com/chdb-io/chdb/releases) - - run `make update_libchdb` to download and extract libchdb.so. or - - run `make install` to install libchdb.so -2. Build `chdb-go` +### Install libchdb.so +1. Install [`libchdb`](https://github.com/chdb-io/chdb/releases) + - curl -sL https://lib.chdb.io | bash + +### Install chdb-go +1. Install `chdb-go` + - `go install github.com/chdb-io/chdb-go@latest` +2. Run `chdb-go` with or without persistent `--path` + - run `$GOPATH/bin/chdb-go` + +### or Build from source +1. Build `chdb-go` - run `make build` -3. Run `chdb-go` with or without persistent `--path` +2. Run `chdb-go` with or without persistent `--path` - run `./chdb-go` ## chdb-go CLI diff --git a/chdbstable/chdb.go b/chdbstable/chdb.go index 65f6f2e..c02aba2 100644 --- a/chdbstable/chdb.go +++ b/chdbstable/chdb.go @@ -1,7 +1,7 @@ package chdbstable /* -#cgo LDFLAGS: -L. -lchdb +#cgo LDFLAGS: -L/usr/local/lib -lchdb #include // Include the C standard library for C.free #include "chdb.h" */ diff --git a/go.mod b/go.mod index a037da0..332f502 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/chdb-io/chdb-go -go 1.21.5 +go 1.21 require ( github.com/apache/arrow/go/v14 v14.0.2