<commit_before>package service

import (
	"io"
	"io/ioutil"
	"os"
	"path/filepath"
	"text/template"

	"github.com/builderscon/octav/octav/gettext"
)

func Template() *TemplateSvc {
	var t *template.Template
	filepath.Walk("template", func(path string, info os.FileInfo, err error) error {
		if err != nil {
			if info.IsDir() {
				return filepath.SkipDir
			}
			return nil
		}

		b, err := ioutil.ReadFile(path)
		if err != nil {
			return err
		}

		if t == nil {
			t = template.New(path).Funcs(map[string]interface{}{
				"gettext": gettext.Get,
			})
		}

		if _, err := t.Parse(string(b)); err != nil {
			return err
		}
		return nil
	})

	return &TemplateSvc{
		template: t,<commit_msg>check for info == nil<commit_after>package service

import (
	"io"
	"io/ioutil"
	"os"
	"path/filepath"
	"text/template"

	"github.com/builderscon/octav/octav/gettext"
)

func Template() *TemplateSvc {
	var t *template.Template
	filepath.Walk("template", func(path string, info os.FileInfo, err error) error {
		if err != nil {
			if info != nil && info.IsDir() {
				return filepath.SkipDir
			}
			return nil
		}

		b, err := ioutil.ReadFile(path)
		if err != nil {
			return err
		}

		if t == nil {
			t = template.New(path).Funcs(map[string]interface{}{
				"gettext": gettext.Get,
			})
		}

		if _, err := t.Parse(string(b)); err != nil {
			return err
		}
		return nil
	})

	return &TemplateSvc{
		template: t,
{'fraction_non_alphanumeric': 0.15024805102763997, 'fraction_numerical': 0.0, 'mean_word_length': 3.069164265129683, 'pattern_counts': {'":': 2, '<': 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': '4118952', 'n_tokens_mistral': 611, 'n_tokens_neox': 538, 'n_words': 124}