<commit_before>package main

import (
	"encoding/gob"
	"os"
	"path/filepath"
)

var locs = make(map[string]int)
var dbFile = filepath.Join(os.Getenv("HOME"), ".wdate")

func loadDB() error {
	if !isFileExist(dbFile) {
		return nil
	}

	f, err := os.Open(dbFile)
	if err != nil {
		return err
	}

	dec := gob.NewDecoder(f)
	err = dec.Decode(&locs)
	if err != nil {
		return err
	}
	return nil
}

func addLocation(name string, offset int) error {
	locs[name] = offset
	f, err := os.Create(dbFile)
	if err != nil {
		return err
	}

	enc := gob.NewEncoder(f)
	err = enc.Encode(locs)
	if err != nil {
		return err
	}

	return nil
}

func removeLocation(name string) error {
	delete(locs, "name")
	f, err := os.Create(dbFile)
	if err != nil {
		return err
	}

	enc := gob.NewEncoder(f)
	err = enc.Encode(locs)
	if err != nil {
		return err
	}<commit_msg>fix stupid bug on removeLocation()<commit_after>package main

import (
	"encoding/gob"
	"os"
	"path/filepath"
)

var locs = make(map[string]int)
var dbFile = filepath.Join(os.Getenv("HOME"), ".wdate")

func loadDB() error {
	if !isFileExist(dbFile) {
		return nil
	}

	f, err := os.Open(dbFile)
	if err != nil {
		return err
	}

	dec := gob.NewDecoder(f)
	err = dec.Decode(&locs)
	if err != nil {
		return err
	}
	return nil
}

func addLocation(name string, offset int) error {
	locs[name] = offset
	f, err := os.Create(dbFile)
	if err != nil {
		return err
	}

	enc := gob.NewEncoder(f)
	err = enc.Encode(locs)
	if err != nil {
		return err
	}

	return nil
}

func removeLocation(name string) error {
	delete(locs, name)
	f, err := os.Create(dbFile)
	if err != nil {
		return err
	}

	enc := gob.NewEncoder(f)
	err = enc.Encode(locs)
	if err != nil {
		return err
	}
{'fraction_non_alphanumeric': 0.1469387755102041, 'fraction_numerical': 0.0, 'mean_word_length': 3.3443037974683545, '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': '5634809', 'n_tokens_mistral': 720, 'n_tokens_neox': 694, 'n_words': 182}