package types import "fmt" type TomlTypeError struct { Value any } func (te *TomlTypeError) Error() string { return fmt.Sprintf("unsupported type: %T", te.Value) } func (is *IntOrString) UnmarshalTOML(val any) error { switch v := val.(type) { case string: is.isInt = false is.strVal = v return nil case int64: is.isInt = true is.intVal = int(v) return nil } return &TomlTypeError{Value: val} }