<commit_before>// Copyright (C) 2014 <NAME> <<EMAIL>>
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.

package gozelle

import (
	"net/url"
	"reflect"
	"strconv"
	"strings"
)

func structToValues(i interface{}, values url.Values) {
	val := reflect.ValueOf(i).Elem()
	typ := val.Type()
	for i := 0; i < val.NumField(); i++ {
		f := val.Field(i)
		var v string
		switch f.Interface().(type) {
		case int:
			if f.Int() != 0 {
				v = strconv.FormatInt(f.Int(), 10)
			}
		case float32:
			v = strconv.FormatFloat(f.Float(), 'f', 4, 32)
		case float64:
			v = strconv.FormatFloat(f.Float(), 'f', 4, 64)
		case bool:
			if f.Bool() {
				v = "1"
			}
		case string:
			f.String()
		}
		if v != "" {
			values.Set(strings.ToLower(typ.Field(i).Name), v)
		}
	}
}<commit_msg>fix string values not being set<commit_after>// Copyright (C) 2014 <NAME> <<EMAIL>>
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.

package gozelle

import (
	"net/url"
	"reflect"
	"strconv"
	"strings"
)

func structToValues(i interface{}, values url.Values) {
	val := reflect.ValueOf(i).Elem()
	typ := val.Type()
	for i := 0; i < val.NumField(); i++ {
		f := val.Field(i)
		var v string
		switch f.Interface().(type) {
		case int:
			if f.Int() != 0 {
				v = strconv.FormatInt(f.Int(), 10)
			}
		case float32:
			v = strconv.FormatFloat(f.Float(), 'f', 4, 32)
		case float64:
			v = strconv.FormatFloat(f.Float(), 'f', 4, 64)
		case bool:
			if f.Bool() {
				v = "1"
			}
		case string:
			v = f.String()
		}
		if v != "" {
			values.Set(strings.ToLower(typ.Field(i).Name), v)
		}
	}
}
{'fraction_non_alphanumeric': 0.17938021454112038, 'fraction_numerical': 0.02264600715137068, 'mean_word_length': 2.8509174311926606, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '839213', 'n_tokens_mistral': 756, 'n_tokens_neox': 656, 'n_words': 184}