spf13/cast

safe and easy casting from one type to another in Go

View on GitHub ↗Jump to charts ↓

Summary Information

Updated 4 minutes ago
Type:Library / SDKCategory(s):Core & Utility LibrariesLanguages & Runtimes
Added to GitGenius on September 17th, 2026
Created on April 3rd, 2014
Open Issues & Pull Requests: 87 (+0)
GitHub issues: Enabled
Number of forks: 336
Total Stargazers: 3,979 (+0)
Total Subscribers: 32 (+0)

Repository Insights (GitGenius)

Median issue/PR response: 60.0 days
Mean response time: 371.1 days
90th percentile: 926.2 days
Tracked items: 36

Most active contributors

Sign in to see contributor activity.

Charts & Analytics

Fetching additional details & charts...

Issue Activity (beta)

Open issues: 13
New in 7 days: 0
Closed in 7 days: 0
Avg open age: 415 days
Stale 30+ days: 13
Stale 90+ days: 11

Recent activity

Opened in 7 days: 0
Closed in 7 days: 0
Comments in 7 days: 0
Events in 7 days: 0

Top labels

No label distribution available yet.

Most active issues this week

No issue events were indexed in the last 7 days.

Detailed Description

Cast is a Go library that provides safe and easy type conversion between different Go types.

Cast solves the problem of converting between types when working with dynamic data, particularly when that data comes from untyped sources like YAML, TOML, or JSON. Rather than relying on Go's type assertions alone, Cast provides a set of conversion functions that intelligently handle common conversions. For example, it can convert a string representation of a number into an actual integer, or convert various types to strings. The library takes a conservative approach: it only performs conversions when the transformation is unambiguous, and it returns zero or nil values rather than guessing at intent when conversion is impossible.

Cast is well-suited for projects that consume or manipulate dynamic data from configuration files or other untyped sources. It provides two families of conversion methods: the To_____ functions that return a value and silently return zero values on failure, and the To_____E variants that also return an error indicating whether the conversion succeeded. This design lets developers choose between convenience and explicit error handling depending on their needs. The library was developed for use in Hugo, a static site generator, which reflects its origin in handling metadata from multiple formats.

The project experiences slow response times to issues and pull requests, with first responses often taking weeks or longer.