MCPcopy
hub / github.com/rclone/rclone / GetInt64

Method GetInt64

fs/rc/params.go:159–182  ·  view source on GitHub ↗

GetInt64 gets an int64 parameter from the input If the parameter isn't found then error will be of type ErrParamNotFound and the returned value will be 0.

(key string)

Source from the content-addressed store, hash-verified

157// If the parameter isn't found then error will be of type
158// ErrParamNotFound and the returned value will be 0.
159func (p Params) GetInt64(key string) (int64, error) {
160 value, err := p.Get(key)
161 if err != nil {
162 return 0, err
163 }
164 switch x := value.(type) {
165 case int:
166 return int64(x), nil
167 case int64:
168 return x, nil
169 case float64:
170 if x > math.MaxInt64 || x < math.MinInt64 {
171 return 0, ErrParamInvalid{fmt.Errorf("key %q (%v) overflows int64 ", key, value)}
172 }
173 return int64(x), nil
174 case string:
175 i, err := strconv.ParseInt(x, 10, 0)
176 if err != nil {
177 return 0, ErrParamInvalid{fmt.Errorf("couldn't parse key %q (%v) as int64: %w", key, value, err)}
178 }
179 return i, nil
180 }
181 return 0, ErrParamInvalid{fmt.Errorf("expecting int64 value for key %q (was %T)", key, value)}
182}
183
184// GetFloat64 gets a float64 parameter from the input
185//

Callers 11

TestParamsGetInt64Function · 0.95
rcQueueSetExpiryFunction · 0.80
rcBisyncFunction · 0.80
rcQuitFunction · 0.80
rcSetBlockProfileRateFunction · 0.80
rcSetSoftMemoryLimitFunction · 0.80
rcSetGCPercentFunction · 0.80
rcJobStatusFunction · 0.80
rcJobStopFunction · 0.80
rcBatchFunction · 0.80

Calls 2

GetMethod · 0.95
ErrorfMethod · 0.45

Tested by 1

TestParamsGetInt64Function · 0.76