Created
July 17, 2019 20:09
-
-
Save fuziontech/a0cf5f709b5f33d88d06f896fee2c4e4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gore> x := reflect.TypeOf(float64(5)) | |
&reflect.rtype{ | |
size: 0x8, | |
ptrdata: 0x0, | |
hash: 0x2ea27ffb, | |
tflag: 0x07, | |
align: 0x08, | |
fieldAlign: 0x08, | |
kind: 0x8e, | |
alg: &reflect.typeAlg{ | |
hash: func(unsafe.Pointer, uintptr) uintptr {...}, | |
equal: func(unsafe.Pointer, unsafe.Pointer) bool {...}, | |
}, | |
gcdata: &0x01, | |
str: 9803, | |
ptrToThis: 53152, | |
} | |
gore> z := reflect.New(reflect.TypeOf(float64(45.5))).Elem().Interface() | |
0.000000 | |
gore> z = 45.5 | |
45.500000 | |
gore> a := map[string]interface{}{"shit": 1} | |
map[string]interface {}{ | |
"shit": 1, | |
} | |
gore> a["storm"] = z | |
45.500000 | |
gore> a | |
map[string]interface {}{ | |
"shit": 1, | |
"storm": 45.500000, | |
} | |
gore> json.Marshal(&a) | |
[]uint8{ | |
0x7b, 0x22, 0x73, 0x68, 0x69, 0x74, 0x22, 0x3a, 0x31, 0x2c, 0x22, 0x73, 0x74, 0x6f, 0x72, 0x6d, | |
0x22, 0x3a, 0x34, 0x35, 0x2e, 0x35, 0x7d, | |
} | |
nil | |
gore> string(json.Marshal(&a)) | |
multiple-value json.Marshal() in single-value context | |
gore> b := json.Marshal(&a) | |
assignment mismatch: 1 variable but json.Marshal returns 2 values | |
gore> b, _ := json.Marshal(&a) | |
[]uint8{ | |
0x7b, 0x22, 0x73, 0x68, 0x69, 0x74, 0x22, 0x3a, 0x31, 0x2c, 0x22, 0x73, 0x74, 0x6f, 0x72, 0x6d, | |
0x22, 0x3a, 0x34, 0x35, 0x2e, 0x35, 0x7d, | |
} | |
gore> string(b) | |
"{\"shit\":1,\"storm\":45.5}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment