mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2025-11-10 08:20:35 +08:00
28 lines
386 B
Go
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>
|
|
}
|