I made a custom type for my IDs:
type ID uint
func (id ID) MarshalJSON() ([]byte, error) {
e, _ := HashIDs.Encode([]int{int(id)})
fmt.Println(e) /// 34gj
return []byte(e), nil
}
func (id *ID) Scan(value interface{}) error {
*id = ID(value.(int64))
return nil
}
I use the HashIDs package to encode my ids so that user wont be able to read them on client side. But I'm getting this error:
json: error calling MarshalJSON for type types.ID: invalid character 'g' after top-level value