<commit_before>package golib

import (
	"encoding/json"
	"flag"
	"fmt"
	"io/ioutil"
	"path/filepath"
)

var (
	current, pathError = filepath.Abs(".")
	configDir          = flag.String("conf", current, "config.json at directory")
)

// LoadConfig is read the configuration from the JSON file into the structure
func LoadConfig(config interface{}, customPath string) error {
	if pathError != nil {
		return pathError
	}

	var configPath string
	if customPath != "" {
		configPath = customPath
	} else {
		flag.Parse()
		// The default is the same directory as the executable file
		if configDir == nil {
			configPath = current
		} else {
			configPath = (*configDir)
		}
	}

	// Read from config.json<commit_msg>modify: filepath.Abs -> os.Executable<commit_after>package golib

import (
	"encoding/json"
	"flag"
	"fmt"
	"io/ioutil"
	"os"
	"path/filepath"
)

var (
	executable, pathError = os.Executable()
	configDir             = flag.String("conf", executable, "config.json at directory")
)

// LoadConfig is read the configuration from the JSON file into the structure
func LoadConfig(config interface{}, customPath string) error {
	if pathError != nil {
		return pathError
	}

	var configPath string
	if customPath != "" {
		configPath = customPath
	} else {
		flag.Parse()
		// The default is the same directory as the executable file
		if configDir == nil {
			configPath = executable
		} else {
			configPath = (*configDir)
		}
	}

	// Read from config.json
{'fraction_non_alphanumeric': 0.11080711354309165, 'fraction_numerical': 0.0, 'mean_word_length': 3.419939577039275, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '7398552', 'n_tokens_mistral': 495, 'n_tokens_neox': 464, 'n_words': 144}