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

Support handle convert INT with a string as a float #179

Closed
KiddoV opened this issue Jul 1, 2024 · 1 comment
Closed

Support handle convert INT with a string as a float #179

KiddoV opened this issue Jul 1, 2024 · 1 comment
Assignees

Comments

@KiddoV
Copy link
Contributor

KiddoV commented Jul 1, 2024

Describe the bug

Support converting from STRING as a float to INT as well.
Currently it would be failure to do something like the below code...

To Reproduce

package main

import (
	"fmt"

	gu "github.com/gookit/goutil"
	gmt "github.com/gookit/goutil/mathutil"
)

func main() {
	fmt.Println(gmt.IntOrDefault("12.000", 0)) //Failed --> default to 0
	fmt.Println(gu.Int("12.000")) //Failed --> return 0
	fmt.Println(gmt.IntOrErr("12.000")) //return: 0 strconv.Atoi: parsing "12.000": invalid syntax
}
@KiddoV
Copy link
Contributor Author

KiddoV commented Jul 2, 2024

Done in #180

@KiddoV KiddoV closed this as completed Jul 2, 2024
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

No branches or pull requests

2 participants