golangGolang

🐼 Panda-Auth Go! - Golang Library Documentation

βš™οΈ Installation & Setup

1. Get the Library

First, you need to obtain the Panda-Auth Go library files.

2. Project Integration

Once downloaded, place the PandaAuth.go file (or the entire library package if structured as such) directly into your Go project's folder.

Example Folder Structure:

your-go-project/
β”œβ”€β”€ main.go             // Your main application file
β”œβ”€β”€ PandaAuth.go        // The Panda-Auth library file
└── go.mod              // (if using Go modules)
PandaAuth.go in project folder

After placing the file, your project should be able to access the functions provided by the Panda-Auth library. If the library is a package, you'll import it as usual in your .go files.

3. Dependencies

The Panda-Auth library and example usage may rely on the following external Go packages:

User-Side (for example, clipboard interaction):

  • github.com/atotto/clipboard

Library Internal Dependencies:

  • crypto/sha256

  • encoding/json

  • fmt

  • io

  • net/http

If you don't have these dependencies installed in your Go environment, you can get them using the Go CLI:

Alternatively, if your project uses Go modules (go.mod file), these dependencies might be managed automatically when you build or run your project.

πŸ“š Available Functions

The Panda-Auth Go library provides the following core functions for key validation and retrieval.

ValidateKey(key string, service string) bool

Checks with the Panda Development API if the provided standard license key is valid for the specified service. The validation process is secured, potentially involving checks against IP address and using SHA256 hashing for data integrity.

  • Parameters:

    • key (string): The license key string to validate.

    • service (string): Your unique service identifier.

  • Returns:

    • bool: true if the key is valid, false otherwise.

ValidatePremiumKey(key string, service string) bool

Similar to ValidateKey, but specifically checks if the provided key is a premium license key and is valid for the specified service. This allows for differentiating access levels or features based on key type.

  • Parameters:

    • key (string): The premium license key string to validate.

    • service (string): Your unique service identifier.

  • Returns:

    • bool: true if the key is a valid premium key, false otherwise.

Example Usage (ValidateKey / ValidatePremiumKey):

If the validation is successful, your application can proceed. A successful console output might look like:

Successful validation output (Sample output from the Go example)

GetKey(service string) string

Generates and returns a URL that users can visit to obtain a license key for the specified service. The key retrieval process might be linked to the user's IP address and secured using SHA256.

  • Parameters:

    • service (string): Your unique service identifier for which the key is to be generated.

  • Returns:

    • string: A URL string for key retrieval.

circle-exclamation

Example Usage (GetKey):

This example demonstrates getting the key URL and copying it to the user's clipboard.

πŸš€ Complete Example

A full, pre-made example for testing the library, including source code, is available in the official Panda libraries repository. You can find the Test release here: PandaKS_Libraries Golang Releasesarrow-up-right

Here's the code from the example:

This example prompts the user for a key, attempts to validate it first as a premium key, then as a standard key, and if both fail, provides a link to get a new key.


Remember to replace placeholder values like "riotdevkit" and example keys with your actual service identifiers and user-provided keys.

Last updated