Skip to content

feat: support type casting for interfaces created from basic types - #235

Closed
VarusHsu wants to merge 1 commit into
spf13:masterfrom
VarusHsu:master
Closed

VarusHsu wants to merge 1 commit into
spf13:masterfrom
VarusHsu:master

Conversation

@VarusHsu

Copy link
Copy Markdown

This PR introduces a function that enables type casting for interface{} values that originate from basic types (e.g., int, float64, string, bool). The function extracts the native value from an interface{} and returns it in its corresponding Go primitive type.

type enum int

const (
    enumOne enum = iota + 1
)

fmt.Println(cast.ToInt64(enumOne) == int64(1)) // true

@VarusHsu

VarusHsu commented Feb 20, 2025 •

Copy link
Copy Markdown
Author

This pr also resolves #215 #165 #163

This was referenced Jun 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant