libdns / namesilo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NameSilo DNS for libdns

Go Reference

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

Authentication

In order to use NameSilo DNS for libdns, the NameSilo API key is required as the token. One can obtain it on the API Manager page within one's account.

Example

The following example shows how to retrieve the DNS records.

package main

import (
	"context"
	"fmt"
	"os"

	"github.com/libdns/namesilo"
)

func main() {
	token := os.Getenv("LIBDNS_NAMESILO_TOKEN")
	if token == "" {
		fmt.Println("LIBDNS_NAMESILO_TOKEN not set")
		return
	}

	zone := os.Getenv("LIBDNS_NAMESILO_ZONE")
	if token == "" {
		fmt.Println("LIBDNS_NAMESILO_ZONE not set")
		return
	}

	p := &namesilo.Provider{
		AuthAPIToken: token,
	}

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

	fmt.Println(records)
}

About

License:MIT License


Languages

Language:Go 100.0%