github.com/cosmos/cosmos-proto@v1.0.0-beta.3/support/timepb/cmp_example_test.go (about) 1 package timepb 2 3 import ( 4 "fmt" 5 6 durpb "google.golang.org/protobuf/types/known/durationpb" 7 tspb "google.golang.org/protobuf/types/known/timestamppb" 8 ) 9 10 func ExampleAdd() { 11 t1 := &tspb.Timestamp{Seconds: 10, Nanos: 1} 12 d := &durpb.Duration{Seconds: 1, Nanos: 1e9 - 1} 13 t2 := Add(t1, d) 14 15 fmt.Println(Compare(&tspb.Timestamp{Seconds: 12, Nanos: 0}, t2) == 0) 16 fmt.Println(Compare(&tspb.Timestamp{Seconds: 10, Nanos: 1}, t1) == 0) 17 fmt.Println(Compare(t1, t2)) 18 // Output: 19 // true 20 // true 21 // -1 22 }