MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / GetFloat

Method GetFloat

options/options.go:237–271  ·  view source on GitHub ↗

GetFloat retrieves a float64 value from the options. If the key does not exist, GetFloat returns the provided default value. If the key value exists but the value is of a different float or integer type, GetFloat converts it to float64. If the key exists but the value is not a float or integer type,

(key string, def float64)

Source from the content-addressed store, hash-verified

235// GetFloat converts it to float64.
236// If the key exists but the value is not a float or integer type, GetFloat panics.
237func (o *Options) GetFloat(key string, def float64) float64 {
238 v, ok := o.m[key]
239 if !ok {
240 return def
241 }
242
243 switch t := v.(type) {
244 case int:
245 return float64(t)
246 case int8:
247 return float64(t)
248 case int16:
249 return float64(t)
250 case int32:
251 return float64(t)
252 case int64:
253 return float64(t)
254 case uint:
255 return float64(t)
256 case uint8:
257 return float64(t)
258 case uint16:
259 return float64(t)
260 case uint32:
261 return float64(t)
262 case uint64:
263 return float64(t)
264 case float32:
265 return float64(t)
266 case float64:
267 return t
268 default:
269 panic(newTypeMismatchError(key, v, def))
270 }
271}
272
273// GetString retrieves a string value.
274// If the key doesn't exist, it returns the provided default value.

Callers 15

TestGetFloatMethod · 0.80
TestParsePathExtendMethod · 0.80
TestParsePathCropMethod · 0.80
TestParsePathBlurMethod · 0.80
TestParsePathSharpenMethod · 0.80
TestParsePathDprMethod · 0.80
TestParsePathPresetMethod · 0.80

Calls 1

newTypeMismatchErrorFunction · 0.85

Tested by 15

TestGetFloatMethod · 0.64
TestParsePathExtendMethod · 0.64
TestParsePathCropMethod · 0.64
TestParsePathBlurMethod · 0.64
TestParsePathSharpenMethod · 0.64
TestParsePathDprMethod · 0.64
TestParsePathPresetMethod · 0.64