<commit_before>package segment

import (
	"bytes"
	"fmt"
	"log"
	"os"
	"syscall"
	//"reflect"
	"github.com/brandonvfx/go-prompt/config"
	"github.com/brandonvfx/go-prompt/prompt"
)

func ReadOnlySegment(cwd string, last_bg int, conf config.Config, buffer *bytes.Buffer) int {
	cwd, err := os.Getwd()
	if err != nil {
		log.Println(err)
		return last_bg
	}
	cwd_stat, err := os.Stat(cwd)
	dir_uid := cwd_stat.Sys().(*syscall.Stat_t).Uid
	dir_gid := cwd_stat.Sys().(*syscall.Stat_t).Gid
	cwd_mode := cwd_stat.Mode()
	if err != nil {
		log.Println(err)
		return last_bg
	}

	if cwd_mode&0002 != 0 {
		return last_bg
	} else if cwd_mode&0020 != 0 && dir_gid == uint32(os.Getgid()) {
		return last_bg
	} else if cwd_mode&0200 != 0 && dir_uid == uint32(os.Getuid()) {
		return last_bg
	} else {
		prompt.SegmentConnector(last_bg, conf.Theme["read_only_bg"], conf, buffer)
		buffer.WriteString(prompt.Color(38, conf.Theme["read_only_fg"]))
		buffer.WriteString(prompt.Color(48, conf.Theme["read_only_bg"]))
		buffer.WriteString(fmt.Sprintf(" %s ", conf.Symbols["lock"]))
		return conf.Theme["read_only_bg"]
	}
}<commit_msg>Fixing go 1.0 bug<commit_after>package segment

import (
	"bytes"
	"fmt"
	"log"
	"os"
	"syscall"
	//"reflect"
	"github.com/brandonvfx/go-prompt/config"
	"github.com/brandonvfx/go-prompt/prompt"
)

func ReadOnlySegment(cwd string, last_bg int, conf config.Config, buffer *bytes.Buffer) int {
	cwd, err := os.Getwd()
	if err != nil {
		log.Println(err)
		return last_bg
	}
	cwd_stat, err := os.Stat(cwd)
	dir_uid := cwd_stat.Sys().(*syscall.Stat_t).Uid
	dir_gid := cwd_stat.Sys().(*syscall.Stat_t).Gid
	cwd_mode := cwd_stat.Mode()
	if err != nil {
		log.Println(err)
		return last_bg
	}

	if cwd_mode&0002 != 0 {
		return last_bg
	} else if cwd_mode&0020 != 0 && dir_gid == uint32(os.Getgid()) {
		return last_bg
	} else if cwd_mode&0200 != 0 && dir_uid == uint32(os.Getuid()) {
		return last_bg
	}

	prompt.SegmentConnector(last_bg, conf.Theme["read_only_bg"], conf, buffer)
	buffer.WriteString(prompt.Color(38, conf.Theme["read_only_fg"]))
	buffer.WriteString(prompt.Color(48, conf.Theme["read_only_bg"]))
	buffer.WriteString(fmt.Sprintf(" %s ", conf.Symbols["lock"]))
	return conf.Theme["read_only_bg"]
}
{'fraction_non_alphanumeric': 0.1671171171171171, 'fraction_numerical': 0.021621621621621623, 'mean_word_length': 4.594458438287154, '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': '7350914', 'n_tokens_mistral': 987, 'n_tokens_neox': 902, 'n_words': 162}