Skip to content

Latest commit

 

History

History
44 lines (31 loc) · 1010 Bytes

README.md

File metadata and controls

44 lines (31 loc) · 1010 Bytes

Headscale Client Go

Go Reference Go Report Card

A client implementation for the Headscale HTTP API.

Example (Using API Key)

package main

import (
	"context"
	"fmt"
	"log/slog"
	"os"

	hsClient "github.com/hibare/headscale-client-go"
)

func main() {
	slog.SetLogLoggerLevel(slog.LevelDebug) // Optional

	serverUrl := os.Getenv("HS_SERVER_URL")
	apiToken := os.Getenv("HS_API_TOKEN")

	client, err := hsClient.NewClient(serverUrl, apiToken, hsClient.HeadscaleClientOptions{})
	if err != nil {
		panic(err)
	}

	nodes, err := client.Nodes().List(context.Background())
	if err != nil {
		panic(err)
	}

	for _, node := range nodes.Nodes {
		fmt.Printf("Node: %s\n", node.Name)
	}

}