Use the Go SDK
Updated at:
This topic provides an example of how to use the Go SDK.
Download address
The iGraph Go SDK allows developers to use Go programs to interact with the graph engine service.
Configuration
/* Required configurations. Specify the endpoint, username, and password. */
var client = aliyun_igraph_go_sdk.NewClient("your_endpoint", "your_user_name", "your_password", "your_src")
/*
your_endpoint: igraph-cn-xxxx.igraph.aliyuncs.com
your_user_name: The username that you set when you purchased the instance.
your_pass_word: The password that you set when you purchased the instance.
your_src: An identifier used to mark the source.
RequestTimeout: The request timeout period. The default value is 1 s.
MaxConnsPerHost: The maximum number of connections per host. The default value is 512.
*/
var config = aliyun_igraph_go_sdk.ClientConfig{
MaxConnsPerHost: 128,
RequestTimeout: 100 * time.Millisecond,
}
Query example
var client = aliyun_igraph_go_sdk.NewClient("http://igraph-cn-xxxx.igraph.aliyuncs", "username", "password", "src")
client.InitConfig(config)
m := make(map[string]string)
readRequest := &aliyun_igraph_go_sdk.ReadRequest{QueryString: "GremlinQuery", QueryParams: m}
resp, err := client.Read(*readRequest)Update example
graphName := "graphName"
instanceName := "igraph-cn-xxxx"
labelName := "labelName"
pkey := "pkfieldName"
request := NewWriteRequest(WriteTypeAdd, instanceName, tableName, labelName, pkey, "", map[string]string{})
request.AddContent("field1", "1")
request.AddContent("field2", "1")
request.AddContent("field3", "1")
request.AddContent(pkey, "1")
resp, err := client.Write(*request)Is this page helpful?