// Psycho Key SDK — Go example integration // Place psychokey.go in package psychokey and run from your main module. package main import ( "bufio" "fmt" "os" "strings" "time" "example/psychokey" ) func main() { client, err := psychokey.NewClient(psychokey.Config{ App: "my-app", ApiSecret: "REPLACE_WITH_64_HEX_PRODUCT_SECRET", Version: "1.0.0", }) if err != nil { panic(err) } fmt.Println("HWID:", client.HWID()) hs := client.Init() if !hs.Ok { fmt.Printf("Handshake failed: %s — %s\n", hs.Code, hs.Message) return } fmt.Println("Server reachable") reader := bufio.NewReader(os.Stdin) fmt.Print("Enter license key: ") key, _ := reader.ReadString('\n') key = strings.TrimSpace(key) res := client.Auth(key) if !res.Ok { fmt.Printf("Access denied: %s — %s\n", res.Code, res.Message) if res.Code == "HWID_LIMIT" || res.Code == "HWID_MISMATCH" { fmt.Print("Reset HWID? [y/N]: ") ans, _ := reader.ReadString('\n') if strings.EqualFold(strings.TrimSpace(ans), "y") { res = client.ResetHWID(key) if !res.Ok { fmt.Println("Reset failed:", res.Code) return } } else { return } } else { return } } fmt.Printf("License accepted (%s)\n", res.License.Status) for i := 0; i < 3; i++ { time.Sleep(3 * time.Second) hb := client.Heartbeat() if !hb.Ok { fmt.Println("Session invalidated:", hb.Code) return } fmt.Printf("Heartbeat OK (%ds left)\n", hb.License.SecondsLeft) } client.Logout() fmt.Println("Done.") }