Exemple #1
0
func main() {
	s := new(obj)
	s.Output = "Arief Darmawan"
	sb, _ := tk.EncodeByte(s)
	fmt.Printf("Encoded: %v \n", s)
	result := new(obj)
	e := tk.DecodeByte(sb, &result)
	if e != nil {
		fmt.Println("Error decoding: ", e.Error())
	}
	fmt.Printf("Decode: %v \n", result.Output)
}
Exemple #2
0
func getToken() error {
	surl := restPrefix + "auth/init"
	b, e := toolkit.EncodeByte(struct {
		Key    string
		Secret string
	}{"ariefdarmawan", "Password.1"})
	if e != nil {
		return fmt.Errorf("Unable to connect: %s", e.Error())
	}
	r, e := toolkit.HttpCall(surl, "get", b, nil)

	if e != nil {
		return fmt.Errorf("Unable to connect: %s", e.Error())
	}

	token := toolkit.HttpContentM(r).Get("Token", "").(string)
	if token == "" {
		return fmt.Errorf("Wrong token returned")
	}

	return nil
}