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
| // To marshal uint8 array to json as number array | |
| type uint8Array []uint8 | |
| func (a uint8Array) MarshalJSON() ([]byte, error) { | |
| var res string | |
| if a == nil { | |
| res = "null" | |
| } else { | |
| res = strings.Join(strings.Fields(fmt.Sprintf("%d", a)), ",") | |
| } |