25 lines
		
	
	
	
		
			417 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
	
		
			417 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| 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}
 | |
| }
 |