<commit_before>package utils

import (
	"fmt"
	"io/ioutil"
	"os"
	"path/filepath"
	"strings"
)

func AddSudoer() error {
	user := os.Getenv("SUDO_USER")

	path, err := filepath.Abs(os.Args[0])
	if err != nil {
		return err
	}
	sudoer := fmt.Sprintf("%s ALL=(ALL) NOPASSWD: %s", user, path)

	file, err := os.OpenFile("/private/etc/sudoers", os.O_RDWR, 0600)
	if err != nil {
		return err
	}

	defer file.Close()

	sudoers, err := ioutil.ReadAll(file)
	if err != nil {
		return err
	}

	lines := strings.Split(string(sudoers), "\n")<commit_msg>use osext to find path to ourselves<commit_after>package utils

import (
	"fmt"
	"io/ioutil"
	"os"
	"path/filepath"
	"strings"

	"github.com/kardianos/osext"
)

func AddSudoer() error {
	user := os.Getenv("SUDO_USER")

	path, err := osext.Executable()
	if err != nil {
		return err
	}
	sudoer := fmt.Sprintf("%s ALL=(ALL) NOPASSWD: %s", user, path)

	file, err := os.OpenFile("/private/etc/sudoers", os.O_RDWR, 0600)
	if err != nil {
		return err
	}

	defer file.Close()

	sudoers, err := ioutil.ReadAll(file)
	if err != nil {
		return err
	}

	lines := strings.Split(string(sudoers), "\n")
{'fraction_non_alphanumeric': 0.17299205648720212, 'fraction_numerical': 0.00794351279788173, 'mean_word_length': 3.725, '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': '6666754', 'n_tokens_mistral': 499, 'n_tokens_neox': 469, 'n_words': 108}