package main import "fmt" import "strconv" func parseInt(s string) (int, error) { n, err := strconv.Atoi(s) if err != nil { b, err := strconv.ParseBool(s) if err != nil { return 0, err } if b { n = 1 } } return n, err } func main() { fmt.Println(parseInt("true")) }
举报
本版积分规则 发表回复 回帖后跳转到最后一页
Archiver|手机版|小黑屋|学习笔记
GMT+8, 2024-12-21 20:15 , Processed in 0.022584 second(s), 13 queries , APCu On.
Powered by Discuz! X3.5
© 2001-2024 Discuz! Team.