<commit_before>// Copyright (C) 2015 <NAME>.
//
// Licensed onder the MIT license that can be found in the LICENSE file.

package main

import (
	"fmt"
	"os"

	"github.com/Thomasdezeeuw/ini"
)

type config struct {
	Name string
	HTTP struct {
		Host    string
		Port    int
		Address string
	}
}

func main() {
	conf := getConfig("./config.ini")

	fmt.Println("Starting application:", conf.Name) // My app

	// And access its values like so:
	fmt.Println(conf.HTTP.Host)    // example.com
	fmt.Println(conf.HTTP.Port)    // 80
	fmt.Println(conf.HTTP.Address) // example.com:80
}

func getConfig(filepath string) config {
	f, err := os.Open(filepath)
	if err != nil {
		panic(err)
	}
	defer f.Close()

	// Parse the configuration.
	c, err := ini.Parse(f)
	if err != nil {
		panic(err)
	}

	// We can now access the configuration options like so:
	fmt.Println(c["HTTP"]["Host"]) // example.com
	fmt.Println(c["HTTP"]["Port"]) // 80
	fmt.Println()

	// But we usually want to use our own custom configuration. We can decode our
	// configuration into our own configuration variable, like so:
	var conf config
	c.Decode(&conf)

	// And then set another configuration option.
	conf.HTTP.Address = c["HTTP"]["Host"] + ":" + c["HTTP"]["Port"]

	return conf
}<commit_msg>Always check errors<commit_after>// Copyright (C) 2015 <NAME>.
//
// Licensed onder the MIT license that can be found in the LICENSE file.

package main

import (
	"fmt"
	"os"

	"github.com/Thomasdezeeuw/ini"
)

type config struct {
	Name string
	HTTP struct {
		Host    string
		Port    int
		Address string
	}
}

func main() {
	conf := getConfig("./config.ini")

	fmt.Println("Starting application:", conf.Name) // My app

	// And access its values like so:
	fmt.Println(conf.HTTP.Host)    // example.com
	fmt.Println(conf.HTTP.Port)    // 80
	fmt.Println(conf.HTTP.Address) // example.com:80
}

func getConfig(filepath string) config {
	f, err := os.Open(filepath)
	if err != nil {
		panic(err)
	}
	defer f.Close()

	// Parse the configuration.
	c, err := ini.Parse(f)
	if err != nil {
		panic(err)
	}

	// We can now access the configuration options like so:
	fmt.Println(c["HTTP"]["Host"]) // example.com
	fmt.Println(c["HTTP"]["Port"]) // 80
	fmt.Println()

	// But we usually want to use our own custom configuration. We can decode our
	// configuration into our own configuration variable, like so:
	var conf config
	if err := c.Decode(&conf); err != nil {
		panic(err)
	}

	// And then set another configuration option.
	conf.HTTP.Address = c["HTTP"]["Host"] + ":" + c["HTTP"]["Port"]

	return conf
}
{'fraction_non_alphanumeric': 0.14735614307931572, 'fraction_numerical': 0.007776049766718507, 'mean_word_length': 3.211129296235679, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, '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': '5125712', 'n_tokens_mistral': 917, 'n_tokens_neox': 877, 'n_words': 271}