<commit_before>package main

import (
	"github.com/spf13/viper"
	"logger/stderr"
	"reflect"
)

type Config struct {
	Servers map[string]Server
}

func init() {
	viper.SetConfigName("config")
	viper.AddConfigPath("/etc/mouse/")
	viper.AddConfigPath("$HOME/.mouse")
	viper.AddConfigPath(".")

	if err := viper.ReadInConfig(); err != nil {
		stderr.Fatalf("Could not read config file:", err)
	}

	// Temporary(?) fix for HCL problems
	servers := viper.Get("servers")
	if reflect.ValueOf(servers).Kind() == reflect.Slice {
		servers = servers.([]map[string]interface{})[0]
		for key, s := range servers.(map[string]interface{}) {
			if reflect.ValueOf(s).Kind() == reflect.Slice {
				servers.(map[string]interface{})[key] = s.([]map[string]interface{})[0]
				for k, v := range servers.(map[string]interface{})[key].(map[string]interface{}) {
					if reflect.ValueOf(v).Kind() == reflect.Slice {
						switch v.(type) {
						case []interface{}:
							continue
						case []map[string]interface{}:
							for p, b := range v.([]map[string]interface{})[0] {
								v.([]map[string]interface{})[0][p] = b.([]map[string]interface{})[0]
							}

							servers.(map[string]interface{})[key].(map[string]interface{})[k] = v.([]map[string]interface{})[0]
						}
					}
				}
			}
		}

		viper.Set("servers", servers)
	}

	if err := viper.Unmarshal(&config); err != nil {
		stderr.Fatalf("Could not unmarshal config:", err)
	}
}
<commit_msg>Add comment about my ugly HCL block<commit_after>package main

import (
	"github.com/spf13/viper"
	"logger/stderr"
	"reflect"
)

type Config struct {
	Servers map[string]Server
}

func init() {
	viper.SetConfigName("config")
	viper.AddConfigPath("/etc/mouse/")
	viper.AddConfigPath("$HOME/.mouse")
	viper.AddConfigPath(".")

	if err := viper.ReadInConfig(); err != nil {
		stderr.Fatalf("Could not read config file:", err)
	}

	// Temporary(?) fix for HCL problems.
	//
	// As of me writing this, the problem is that currently the HCL parser adds
	// extra arrays for some weird reason.
	//
	// This:
	//
	// servers "fc00" {
	//   ...
	// }
	//
	// Is converted to this [[map:[]]] when it should be converted to [map:[]]
	// on every map.
	//
	// @see https://github.com/hashicorp/hcl/pull/24#issuecomment-69821965
	servers := viper.Get("servers")
	if reflect.ValueOf(servers).Kind() == reflect.Slice {
		servers = servers.([]map[string]interface{})[0]
		for key, s := range servers.(map[string]interface{}) {
			if reflect.ValueOf(s).Kind() == reflect.Slice {
				servers.(map[string]interface{})[key] = s.([]map[string]interface{})[0]
				for k, v := range servers.(map[string]interface{})[key].(map[string]interface{}) {
					if reflect.ValueOf(v).Kind() == reflect.Slice {
						switch v.(type) {
						case []interface{}:
							continue
						case []map[string]interface{}:
							for p, b := range v.([]map[string]interface{})[0] {
								v.([]map[string]interface{})[0][p] = b.([]map[string]interface{})[0]
							}

							servers.(map[string]interface{})[key].(map[string]interface{})[k] = v.([]map[string]interface{})[0]
						}
					}
				}
			}
		}

		viper.Set("servers", servers)
	}

	if err := viper.Unmarshal(&config); err != nil {
		stderr.Fatalf("Could not unmarshal config:", err)
	}
}

{'fraction_non_alphanumeric': 0.1982732038236201, 'fraction_numerical': 0.008633980881899476, 'mean_word_length': 3.5690140845070424, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, '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': '2313023', 'n_tokens_mistral': 1293, 'n_tokens_neox': 1133, 'n_words': 218}