Skip to content

Instantly share code, notes, and snippets.

View ssksameer56's full-sized avatar
😀

Sameer Kolpekwar ssksameer56

😀
View GitHub Profile
@ssksameer56
ssksameer56 / custom_numeric.go
Created November 29, 2022 10:26
Custom Unmarshal functions to support floats and strings interchangabely.
//https://stackoverflow.com/questions/73573695/go-custom-unmarshaler-string-to-float
type CustomFloat float64
type CustomInt int64
func (c *CustomFloat) UnmarshalJSON(b []byte) error {
var s interface{}
if err := json.Unmarshal(b, &s); err != nil {
return err
}
switch v := s.(type) {