Skip to content

Latest commit

 

History

History
54 lines (39 loc) · 1.23 KB

README.md

File metadata and controls

54 lines (39 loc) · 1.23 KB

GCore for libdns

Go Reference

This package implements the libdns interfaces for GCore, allowing you to manage DNS records.

Authenticating

To authenticate you need to supply a GCore API Key.

Example

Here's a minimal example of how to get all DNS records for zone.

// Package main provides a simple example of how to use the libdns-gcore package.
package main

import (
    "context"
    "fmt"
    "os"
    "path/filepath"

    gcore "github.com/libdns/gcore"
)

func main() {
    apiKey := os.Getenv("GCORE_API_KEY")
    if apiKey == "" {
        fmt.Printf("GCORE_API_KEY not set\n")
        return
    }

    if len(os.Args) < 2 {
        fmt.Printf("Usage: %s <zone>\n", filepath.Base(os.Args[0]))
        os.Exit(1)
    }

    zone := os.Args[1]

    provider := &gcore.Provider{
        APIKey: apiKey,
    }

    records, err := provider.GetRecords(context.Background(), zone)
    if err != nil {
        fmt.Printf("Error: %s", err.Error())
        return
    }

    fmt.Println(records)
}