Convert string to integer type in Go?

前端 未结 5 1973
误落风尘
误落风尘 2020-11-30 19:12

I\'m trying to convert a string returned from flag.Arg(n) to an int. What is the idiomatic way to do this in Go?

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-30 19:38

    Try this

    import ("strconv")
    
    value : = "123"
    number,err := strconv.ParseUint(value, 10, 32)
    

提交回复
热议问题