MCPcopy Create free account
hub / github.com/GongShichen/LuminaCode / floatFromSnapshot

Function floatFromSnapshot

skills/persistence.go:441–468  ·  view source on GitHub ↗
(value any)

Source from the content-addressed store, hash-verified

439}
440
441func floatFromSnapshot(value any) (float64, bool) {
442 if !snapshotTruthy(value) {
443 return 0, true
444 }
445 switch v := value.(type) {
446 case float64:
447 return v, true
448 case float32:
449 return float64(v), true
450 case int:
451 return float64(v), true
452 case int64:
453 return float64(v), true
454 case bool:
455 if v {
456 return 1, true
457 }
458 return 0, true
459 case string:
460 parsed, err := strconv.ParseFloat(strings.TrimSpace(v), 64)
461 if err != nil {
462 return 0, false
463 }
464 return parsed, true
465 default:
466 return 0, false
467 }
468}
469
470func snapshotTruthy(value any) bool {
471 switch v := value.(type) {

Callers 1

ImportSnapshotMethod · 0.85

Calls 1

snapshotTruthyFunction · 0.85

Tested by

no test coverage detected