feat: non null slice on parser result
This commit is contained in:
		
							parent
							
								
									2029cc8ae9
								
							
						
					
					
						commit
						18b7193bc0
					
				|  | @ -1,6 +1,7 @@ | ||||||
| package stage | package stage | ||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
|  | 	"encoding/json" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"strconv" | 	"strconv" | ||||||
| 
 | 
 | ||||||
|  | @ -162,8 +163,17 @@ type ParserResult struct { | ||||||
| 	Comment string `json:"comment"` | 	Comment string `json:"comment"` | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| type StageResult struct { | type NonNullSlice[T any] []T | ||||||
| 	Name      string         `json:"name"` | 
 | ||||||
| 	Results   []ParserResult `json:"results"` | func (s NonNullSlice[T]) MarshalJSON() ([]byte, error) { | ||||||
| 	ForceQuit bool           `json:"force_quit"` | 	if len(s) == 0 { | ||||||
|  | 		return []byte("[]"), nil | ||||||
|  | 	} | ||||||
|  | 	return json.Marshal([]T(s)) | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | type StageResult struct { | ||||||
|  | 	Name      string                     `json:"name"` | ||||||
|  | 	Results   NonNullSlice[ParserResult] `json:"results"` | ||||||
|  | 	ForceQuit bool                       `json:"force_quit"` | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user