projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch '14383-java-sdk-double-slash'. Fixes #14383.
[arvados.git]
/
sdk
/
go
/
arvados
/
duration.go
diff --git
a/sdk/go/arvados/duration.go
b/sdk/go/arvados/duration.go
index a64eaacf8347eb2d6937c84e2c1b0598994ce937..25eed010f26c534ef8e36dfa119065731d1e2ac4 100644
(file)
--- a/
sdk/go/arvados/duration.go
+++ b/
sdk/go/arvados/duration.go
@@
-1,3
+1,7
@@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: Apache-2.0
+
package arvados
import (
package arvados
import (
@@
-10,7
+14,7
@@
import (
// a number of nanoseconds.
type Duration time.Duration
// a number of nanoseconds.
type Duration time.Duration
-// UnmarshalJSON implements json.Unmarshaler
+// UnmarshalJSON implements json.Unmarshaler
.
func (d *Duration) UnmarshalJSON(data []byte) error {
if data[0] == '"' {
return d.Set(string(data[1 : len(data)-1]))
func (d *Duration) UnmarshalJSON(data []byte) error {
if data[0] == '"' {
return d.Set(string(data[1 : len(data)-1]))
@@
-18,22
+22,22
@@
func (d *Duration) UnmarshalJSON(data []byte) error {
return fmt.Errorf("duration must be given as a string like \"600s\" or \"1h30m\"")
}
return fmt.Errorf("duration must be given as a string like \"600s\" or \"1h30m\"")
}
-// MarshalJSON implements json.Marshaler
+// MarshalJSON implements json.Marshaler
.
func (d *Duration) MarshalJSON() ([]byte, error) {
return json.Marshal(d.String())
}
func (d *Duration) MarshalJSON() ([]byte, error) {
return json.Marshal(d.String())
}
-// String implements fmt.Stringer
+// String implements fmt.Stringer
.
func (d Duration) String() string {
return time.Duration(d).String()
}
func (d Duration) String() string {
return time.Duration(d).String()
}
-// Duration returns a time.Duration
+// Duration returns a time.Duration
.
func (d Duration) Duration() time.Duration {
return time.Duration(d)
}
func (d Duration) Duration() time.Duration {
return time.Duration(d)
}
-//
Value implements flag.Value
+//
Set implements the flag.Value interface and sets the duration value by using time.ParseDuration to parse the string.
func (d *Duration) Set(s string) error {
dur, err := time.ParseDuration(s)
*d = Duration(dur)
func (d *Duration) Set(s string) error {
dur, err := time.ParseDuration(s)
*d = Duration(dur)