Version 1.7 of the documentation is no longer actively maintained. The site that you are currently viewing is an archived snapshot.
For up-to-date documentation, see the latest version.
A HugeGraph Client SDK tool based on the Go language.
Software Architecture
(Software architecture description)
Installation Tutorial
go get github.com/apache/incubator-hugegraph-toolchain/hugegraph-client-go
Implemented APIs
API
Description
schema
Get schema information
version
Get version information
Usage Instructions
1. Initialize the Client
packagemainimport("log""os""github.com/apache/incubator-hugegraph-toolchain/hugegraph-client-go""github.com/apache/incubator-hugegraph-toolchain/hugegraph-client-go/hgtransport")funcmain(){client,err:=hugegraph.NewCommonClient(hugegraph.Config{Host:"127.0.0.1",Port:8080,Graph:"hugegraph",Username:"",// Fill in the username according to the actual situationPassword:"",// Fill in the password according to the actual situationLogger:&hgtransport.ColorLogger{Output:os.Stdout,EnableRequestBody:true,EnableResponseBody:true,},})iferr!=nil{log.Fatalf("Error creating the client: %s\n",err)}// Use the client for operations..._=client// Avoid "imported and not used" error}
2. Get HugeGraph Version
Get Version Information Using SDK
packagemainimport("fmt""log""os""github.com/apache/incubator-hugegraph-toolchain/hugegraph-client-go""github.com/apache/incubator-hugegraph-toolchain/hugegraph-client-go/hgtransport")// initClient initializes and returns a HugeGraph client instancefuncinitClient()*hugegraph.CommonClient{client,err:=hugegraph.NewCommonClient(hugegraph.Config{Host:"127.0.0.1",Port:8080,Graph:"hugegraph",Username:"",Password:"",Logger:&hgtransport.ColorLogger{Output:os.Stdout,EnableRequestBody:true,EnableResponseBody:true,},})iferr!=nil{log.Fatalf("Error creating the client: %s\n",err)}returnclient}funcgetVersion(){client:=initClient()// Assume client has a Version method that returns version information and an error// res, err := client.Version() // Actual call// Simulate return, as the client.Version() return type in the original README does not fully match the usage heretypeVersionInfostruct{Versionsstruct{Versionstring`json:"version"`Corestring`json:"core"`Gremlinstring`json:"gremlin"`APIstring`json:"api"`}`json:"versions"`// Body io.ReadCloser // Assume there is a Body to close, adjust according to the actual SDK}// Simulate API call and returnres:=&VersionInfo{Versions:struct{Versionstring`json:"version"`Corestring`json:"core"`Gremlinstring`json:"gremlin"`APIstring`json:"api"`}{Version:"1.0.0",// Example versionCore:"1.0.0",Gremlin:"3.x.x",API:"v1",},}// err := error(nil) // Assume no error// if err != nil {// log.Fatalf("Error getting the response: %s\n", err)// }// defer res.Body.Close() // If there is a Body, it needs to be closedfmt.Println(res.Versions)fmt.Println(res.Versions.Version)}funcmain(){getVersion()}
Structure of the Return Value
packagemain// VersionResponse defines the structure returned by the version APItypeVersionResponsestruct{Versionsstruct{Versionstring`json:"version"`// hugegraph versionCorestring`json:"core"`// hugegraph core versionGremlinstring`json:"gremlin"`// hugegraph gremlin versionAPIstring`json:"api"`// hugegraph api version}`json:"versions"`}