Skip to content

Commit

Permalink
fixes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
williamsjokvist committed Oct 13, 2024
1 parent be0dd47 commit 3bb04be
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/storage/txt/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,18 @@ func NewStorage() (*Storage, error) {
func (s *Storage) SaveMatch(match model.Match) error {
v := reflect.ValueOf(match)
t := v.Type()
for i := range t.NumField() {
for i := 0; i < t.NumField(); i++ {
field := t.Field(i).Name
value := v.Field(i)

parsedValue := ""
switch v.Kind() {
switch value.Kind() {
case reflect.Int, reflect.Uint16:
parsedValue = strconv.FormatInt(v.Int(), 10)
parsedValue = strconv.FormatInt(value.Int(), 10)
case reflect.String:
parsedValue = value.String()
default:
return fmt.Errorf("unsupported field type: %s", value.Kind())
}

if err := s.saveTxtFile(fmt.Sprintf("%s.txt", field), parsedValue); err != nil {
Expand Down

0 comments on commit 3bb04be

Please sign in to comment.