Add CONTEXT.md, consumer README skeleton, and package Examples.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package godns_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
godns "gitea.neitzel.de/konrad/go-dns"
|
||||
)
|
||||
|
||||
func ExampleNewClient() {
|
||||
key := godns.TSIG{
|
||||
Name: "exapp-key.",
|
||||
Algorithm: "hmac-sha256",
|
||||
Secret: "dGVzdA==", // base64; construction only — no network call
|
||||
}
|
||||
client, err := godns.NewClient("127.0.0.1:53", "example.com.", key)
|
||||
if err != nil {
|
||||
fmt.Println("err:", err)
|
||||
return
|
||||
}
|
||||
_ = client
|
||||
fmt.Println("ok")
|
||||
// Output: ok
|
||||
}
|
||||
|
||||
func ExampleAdd() {
|
||||
rec, err := godns.A("www.example.com.", 300, net.ParseIP("192.0.2.10"))
|
||||
if err != nil {
|
||||
fmt.Println("err:", err)
|
||||
return
|
||||
}
|
||||
change := godns.Add(rec)
|
||||
fmt.Println(change.Action == godns.ActionAdd, change.Record.Type, change.Record.RData)
|
||||
// Output: true A 192.0.2.10
|
||||
}
|
||||
|
||||
func ExampleDelete() {
|
||||
rec, err := godns.TXT("note.example.com.", 60, "retire")
|
||||
if err != nil {
|
||||
fmt.Println("err:", err)
|
||||
return
|
||||
}
|
||||
change := godns.Delete(rec)
|
||||
fmt.Println(change.Action == godns.ActionDelete, change.Record.Type)
|
||||
// Output: true TXT
|
||||
}
|
||||
Reference in New Issue
Block a user