dnscontrol/pkg/cloudflare-go/duration_test.go
Tom Limoncelli 7fd6a74e0c
CLOUDFLAREAPI: CF_REDIRECT/CF_TEMP_REDIRECT should dtrt using Single Redirects (#3002)
Co-authored-by: Josh Zhang <jzhang1@stackoverflow.com>
2024-06-18 17:38:50 -04:00

28 lines
386 B
Go

package cloudflare
import (
"fmt"
"time"
"github.com/goccy/go-json"
)
func ExampleDuration() {
d := Duration{1 * time.Second}
fmt.Println(d)
buf, err := json.Marshal(d)
fmt.Println(string(buf), err)
err = json.Unmarshal([]byte(`"5s"`), &d)
fmt.Println(d, err)
d.Duration += time.Second
fmt.Println(d, err)
// Output:
// 1s
// "1s" <nil>
// 5s <nil>
// 6s <nil>
}