Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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

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