Leancloud sdk for golang.
go get -u github.com/afeiship/go-leancloud
package main
import (
"fmt"
"log"
"github.com/afeiship/go-leancloud"
"github.com/tidwall/gjson"
)
var client = leancloud.New()
func main() {
// get
result, err := client.Get("my_key")
if err != nil {
log.Fatalf("Failed to get key: %v", err)
}
fmt.Printf("Full result: %+v\n", result)
// set
err = client.Set("my_key", "my_value")
if err != nil {
log.Fatalf("Failed to set key: %v", err)
}
// value
value, err := result.Value()
if err != nil {
log.Fatalf("Failed to get value: %v", err)
}
fmt.Printf("Value: %v\n", value)
// get nested value
value := result.Value
age := gjson.Get(value, "age")
fmt.Printf("Age: %v\n", age)
}