Home

Awesome

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:

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.

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)

(not available)

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

License

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