<commit_before>package config

import (
	"os"
	"path/filepath"

	"github.com/BurntSushi/toml"
)

var conf *Config

func MustGet() *Config {
	if conf == nil {
		panic("config is not set, please call Config.MustRead(pathToConfFile)")
	}

	return conf
}

func MustRead(path string) *Config {
	pwd, err := os.Getwd()
	if err != nil {
		panic(err)
	}

	configPath := filepath.Join(pwd, path)
	if _, err := toml.DecodeFile(configPath, &conf); err != nil {
		panic(err)
	}

	// set environment variable
	env := os.Getenv("SOCIAL_API_ENV")
	if env != "" {
		conf.Environment = env
	}

	// set URI for webserver
	hostname := os.Getenv("SOCIAL_API_HOSTNAME")
	if hostname != "" {
		conf.Uri = hostname
	}

	return conf
}<commit_msg>config: commented to read<commit_after>package config

import (
	"os"
	"path/filepath"

	"github.com/BurntSushi/toml"
)

var conf *Config

func MustGet() *Config {
	if conf == nil {
		panic("config is not set, please call Config.MustRead(pathToConfFile)")
	}

	return conf
}

// MustRead takes a relative file path
// and tries to open and read it into Config struct
// If file is not there or file is not given, it panics
// If the given file is not formatted well panics
func MustRead(path string) *Config {
	// get working directory for joining with given config path
	pwd, err := os.Getwd()
	if err != nil {
		panic(err)
	}

//join working dir and config path
	configPath := filepath.Join(pwd, path)
	if _, err := toml.DecodeFile(configPath, &conf); err != nil {
		panic(err)
	}

	// we can override Environment property of 
	//the config from env variable
	// set environment variable
	env := os.Getenv("SOCIAL_API_ENV")
	if env != "" {
		conf.Environment = env
	}

	// set URI for webserver
	hostname := os.Getenv("SOCIAL_API_HOSTNAME")
	if hostname != "" {
		conf.Uri = hostname
	}

	return conf
}
{'fraction_non_alphanumeric': 0.1248630887185104, 'fraction_numerical': 0.0, 'mean_word_length': 3.533498759305211, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6592270', 'n_tokens_mistral': 663, 'n_tokens_neox': 636, 'n_words': 198}