/nebula-go

Nebula client in Golang

Primary LanguageGo

nebula-go

build status

Official Nebula Go client which communicates with the server using fbthrift.

Please be careful do not to modify the files in the graph directory, these codes were all generated by fbthrift.

Install

$ go get -u -v github.com/vesoft-inc/nebula-go

Usage example

package main

import (
  "log"

  nebula "github.com/vesoft-inc/nebula-go"
  graph "github.com/vesoft-inc/nebula-go/nebula/graph"
)

func main() {
  client, err := nebula.NewClient("127.0.0.1:3699")
  if err != nil {
    log.Fatal(err)
  }

  if err = client.Connect("username", "password"); err != nil {
    log.Fatal(err)
  }
  defer client.Disconnect()

  if resp, err := client.Execute("SHOW HOSTS;"); err != nil {
    log.Fatal(err)
  } else {
    if resp.GetErrorCode() != graph.ErrorCode_SUCCEEDED {
      log.Printf("ErrorCode: %v, ErrorMsg: %s", resp.GetErrorCode(), resp.GetErrorMsg())
    }
  }
}