Skip to content

Commit

Permalink
chore(doc): Update Readme (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
hibare authored Nov 4, 2024
1 parent 88d458c commit 9373e89
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,44 @@
# Headscale Client Go

[![Go Reference](https://pkg.go.dev/badge/github.com/tailscale/tailscale-client-go/v2.svg)](https://pkg.go.dev/github.com/hibare/headscale-client-go)
[![Go Report Card](https://goreportcard.com/badge/github.com/hibare/headscale-client-go)](https://goreportcard.com/report/github.com/hibare/headscale-client-go)

A client implementation for the [Headscale](https://headscale.net) HTTP API.

## Example (Using API Key)

```go
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)
}

}

```

0 comments on commit 9373e89

Please sign in to comment.