Hallo all, 

I've a "stupid" question about the type "int" when used inside json. 
Almost every documentation I've found says int is 32 bit long, so that I 
expect a range from -2.147.483.648 to 2.147.483.647.



So I "mistakely" did that:

type Comment struct {
 ID        int       `json:"id"`
 URL       string    `json:"url"`
 Comment   string    `json:"comment"`
 Html      string    `json:"html"`
 Name      string    `json:"name"`
 Timestamp time.Time `json:"timestamp"`
 Parent    int       `json:"parent"`
}



then some code, where c is *Comment, and..


t := time.Now()
c.ID = int(t.UnixNano() / 1000000)


but, when I wrote c.ID into a JSON file, it resulted in:

1524937580003

which is correct, but cannot fit in 32 bits. 

The version I'm using is 
go version go1.9.4 linux/amd64


is it a bug of this specific version, or is something I didn't got about 
int inside struct json structs, like c.ID? 

many thanks

Milo









-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to