Skip to content

afeiship/go-leancloud

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-leancloud

Leancloud sdk for golang.

installation

go get -u github.com/afeiship/go-leancloud

usage

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)
}

resources