Re: [go-nuts] About the confusion caused by type conversion in golang

2021-01-27 Thread Arunkumar Gudelli
256 considered as `constant`. (untyped) So when we try to convert to byte (which has a range from 0 to 255), it will throw the overflow error. Where `x := uint64(256)` we are giving a type to constant uint64. y := byte(256) // Same error so byte(uint64) will be zero without any errors. regards,

[go-nuts] json unmarshal automatic type conversion issue

2016-12-13 Thread arunkumar
Hi gophers, How to prevent json unmarshal from type conversion. From the below sample code i got the input string converted to float64 package main import ( "fmt" "encoding/json" "reflect" ) func main() { var output interface{} var input = "1" fmt.Println(reflect.TypeOf(input)) json.Unmarshal