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,
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