Source File
duration.go
Belonging Package
github.com/golang/protobuf/ptypes
package ptypes
import (
durationpb
)
const (
maxSeconds = int64(10000 * 365.25 * 24 * 60 * 60)
minSeconds = -maxSeconds
)
func ( *durationpb.Duration) (time.Duration, error) {
if := validateDuration(); != nil {
return 0,
}
:= time.Duration(.Seconds) * time.Second
if int64(/time.Second) != .Seconds {
return 0, fmt.Errorf("duration: %v is out of range for time.Duration", )
}
if .Nanos != 0 {
+= time.Duration(.Nanos) * time.Nanosecond
if ( < 0) != (.Nanos < 0) {
return 0, fmt.Errorf("duration: %v is out of range for time.Duration", )
}
}
return , nil
}
func ( time.Duration) *durationpb.Duration {
:= .Nanoseconds()
:= / 1e9
-= * 1e9
return &durationpb.Duration{
Seconds: int64(),
Nanos: int32(),
}
}
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |