Skip to content

Instantly share code, notes, and snippets.

View CornWorld's full-sized avatar
🕊️
咕咕咕咕咕咕

CornWorld CornWorld

🕊️
咕咕咕咕咕咕
View GitHub Profile
@CornWorld
CornWorld / gist:86d870d4cd4f5ecd9da6dce95898451b
Created January 27, 2024 09:52
Marshal uint8 array to json as number array in Golang
// 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)), ",")
}