# spf13/cast

safe and easy casting from one type to another in Go

Repository: https://github.com/spf13/cast
Canonical: https://ross.abutalabs.com/products/cast
Language: Go
License: MIT
License Family: permissive
Last push: 2026-04-12T08:55:58+00:00

## Health v2 (maintenance only)
Score: 71/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 77, release rhythm 47, longevity 100
- inputs: {"age_days": 4535, "days_push": 143, "days_rel": 359, "gap_med": 29, "n_releases_24m": 6}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 3981, forks 335 (observed 2026-08-28T04:08:31.658550+00:00)

## What it is
Cast is a Go library providing safe and consistent type conversion functions, such as converting interfaces, strings, and numbers between Go types. It was developed for Hugo and is especially useful when handling dynamic data from untyped formats like YAML, TOML, or JSON.

## Use cases
- convert interface{} values to concrete Go types safely
- parse dynamic YAML/TOML/JSON data into typed Go values
- convert numbers to strings and strings to ints without panicking
- handle dynamic content in Go web applications
- get zero values or errors for failed type conversions

## When to choose
- you work with interface{} values from untyped data formats like YAML, TOML, or JSON
- you need non-panicking type conversions with optional error reporting
- you want consistent, intelligent conversion behavior across a codebase

## When to avoid
- you only need simple type assertions on known types
- you need strict parsing with detailed error messages for malformed input
- your project does not use Go

## Facets
- artifact type: library
- maturity: stable
- function: serialization, developer-tools
- domain: developer-tools, programming-languages
- platform: go, cross-platform
- tags: type-conversion, casting, dynamic-data, configuration-parsing

## Member repositories
- spf13/cast (main) score 71

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:08:31.658550+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-29T18:24:16.882267+00:00, confidence not recorded.
  - readme: https://github.com/spf13/cast (fetched 2026-08-28T04:08:31.658550+00:00, sha 2c582f7ed996)
- Data as of 2026-08-30T08:39:29.467469+00:00.
