Skip to content

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

Closed
VarusHsu wants to merge 1 commit intospf13:masterfrom
VarusHsu:master
Closed

feat: support type casting for interfaces created from basic types#235
VarusHsu wants to merge 1 commit intospf13:masterfrom
VarusHsu:master

Conversation

@VarusHsu
Copy link

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
Copy link
Author

VarusHsu commented Feb 20, 2025

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