/go_client

GridDB Go Client

Primary LanguageC++Apache License 2.0Apache-2.0

GridDB Go Client

Overview

GridDB Go Client is developed using GridDB C Client and SWIG (Simplified Wrapper and Interface Generator).

Operating environment

Building of the library and execution of the sample programs have been checked in the following environment.

OS: CentOS 7.9(x64) (GCC 4.8.5)
SWIG: 4.0.2
Go: 1.16/1.18
GridDB C client: V5.0 CE(Community Edition)
GridDB server: V5.0 CE, CentOS 7.9(x64) (GCC 4.8.5)

OS: Ubuntu 18.04(x64) (GCC 7.3.0) / 20.04(x64) (GCC 9.4.0)
SWIG: 4.0.2
Go: 1.16/1.18
GridDB C client: V5.0 CE
GridDB server: V5.0 CE, Ubuntu 18.04(x64) (Note: If you build from source code, please use GCC 4.8.5.)

OS: Windows 10(x64) (gdm64-gcc 10.3.0)
SWIG: 4.0.2
Go: 1.16/1.18
GridDB C client: V5.0 CE
GridDB server: V5.0 CE, CentOS 7.9(x64) (GCC 4.8.5)

QuickStart (CentOS, Ubuntu)

Preparations

Install SWIG as below.

$ wget https://prdownloads.sourceforge.net/swig/swig-4.0.2.tar.gz
$ tar xvfz swig-4.0.2.tar.gz
$ cd swig-4.0.2
$ ./autogen.sh
$ ./configure
$ make
$ sudo make install

Note: If CentOS, you might need to install pcre in advance.
$ sudo yum install pcre2-devel.x86_64

Install Go.

Install GridDB Server and C Client.

Note:

  • If you build Server from source code, please use GCC 4.8.5.

  • If you build C Client from source code, please set LIBRARY_PATH and LD_LIBRARY_PATH.

    Ex.)
    $ export LIBRARY_PATH=$LIBRARY_PATH:$C_CLIENT_HOME/bin
    $ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$C_CLIENT_HOME/bin

Build and Run

1. Set the GOPATH variable for Go module files.

2. Get Go client source code.

    $ go env -w GO111MODULE=off
    $ go get -d github.com/griddb/go_client

3. Run script to generate resource and install Go client

    $ cd $GOPATH/src/github.com/griddb/go_client
    $ ./run_swig.sh
    $ go install

4. Import "github.com/griddb/go_client" in Go.

How to run sample

GridDB Server need to be started in advance.

1. The command to run sample

    $ go run sample/sample1.go <GridDB notification address> <GridDB notification port>
        <GridDB cluster name> <GridDB user> <GridDB password>
      -->Person: name=name02 status=false count=1 lob=[65, 66, 67, 68, 69, 70, 71, 72, 73, 74]

QuickStart (Windows)

Preparations

Install SWIG as below.

Install GO

Install GridDB Server on CentOS. (Note: If you build them from source code, please use GCC 4.8.5.)

Install GridDB C Client.

  • Please refer to https://github.com/griddb/c_client to install GridDB C client.
  • After installing GridDB C client, create folder <go_client>\libs and store gridstore_c.dll (not use gridstore_c.lib) into it.

Set LIBRARY_PATH.

$ set LIBRARY_PATH=%LIBRARY_PATH%:<C client library file directory path>

Install tdm64-gcc

Build and Run in cmd

1. Set the GOPATH variable for Go module files.

2. Get Go client source code.

    $ go env -w GO111MODULE=off
    $ go get -d github.com/griddb/go_client

3. Run script to generate resource and install Go client

    $ cd %GOPATH%/src/github.com/griddb/go_client
    $ ./run_swig.bat
    $ go install

4. Import "github.com/griddb/go_client" in Go.

How to run sample

GridDB Server need to be started in advance.

1. Set PATH

    $ set PATH=%PATH%:<C client library file directory path>

2. The command to run sample

    $ go run sample/sample1.go <GridDB notification address> <GridDB notification port>
        <GridDB cluster name> <GridDB user> <GridDB password>
      -->[ 'name01', false, 1, <Buffer 41 42 43 44 45 46 47 48 49 4a> ]

Function

(available)

  • STRING, BOOL, BYTE, SHORT, INTEGER, LONG, FLOAT, DOUBLE, TIMESTAMP, BLOB type for GridDB
  • put single row, get row with key
  • normal query, aggregation with TQL
  • Multi-Put/Get/Query (batch processing)

(not available)

  • GEOMETRY, Array type for GridDB
  • timeseries-specific function like gsAggregateTimeSeries, gsQueryByTimeSeriesSampling in C client
  • affinity

Please refer to the following files for more detailed information.

Note:

  1. After calling a method getting GridDB object, user must call DeleteClassName() function for each object. If possible, we recommend to use a defer of the DeleteClassName call like sample1.go.
  2. The current API might be changed in the next version. e.g. ContainerInfo()

Community

  • Issues
    Use the GitHub issue function if you have any requests, questions, or bug reports.
  • PullRequest
    Use the GitHub pull request function if you want to contribute code. You'll need to agree GridDB Contributor License Agreement(CLA_rev1.1.pdf). By using the GitHub pull request function, you shall be deemed to have agreed to GridDB Contributor License Agreement.

License

GridDB Go Client source license is Apache License, version 2.0.