// initConfig initializes the config constants
initConfig initializes the config constants
// initConfig initializes the config constants
func initConfig() error {
	re, _ := regexp.Compile(pat)
	r, ok := os.LookupEnv("PCP_DIR")
	if !ok {
		r = "/"
	}
	rootPath = r
	c, ok := os.LookupEnv("PCP_CONF")
	if !ok {
		c = filepath.Join(rootPath, "etc", "pcp.conf")
	}
	confPath = c
	f, err := os.Open(confPath)
	if err != nil {
		return err
	}
	config = make(map[string]string)
	scanner := bufio.NewScanner(f)
	for scanner.Scan() {
		t := scanner.Text()
		if re.MatchString(t) {
			matches := re.FindStringSubmatch(t)
			config[matches[1]] = matches[2]
		}
	}
	return nil
}
func initConfig ( ) error { re , _ := regexp . Compile ( pat ) r , ok := os . LookupEnv ( " " ) if ! ok { r = " " } rootPath = r c , ok := os . LookupEnv ( " " ) if ! ok { c = filepath . Join ( rootPath , " " , " " ) } confPath = c f , err := os . Open ( confPath ) if err != nil { return err } config = make ( map [ string ] string ) scanner := bufio . NewScanner ( f ) for scanner . Scan ( ) { t := scanner . Text ( ) if re . MatchString ( t ) { matches := re . FindStringSubmatch ( t ) config [ matches [ 1 ] ] = matches [ 2 ] } } return nil }
initConfig initializes the config constants
initConfig initializes the config constants
// if we reach at this point, it means we have a valid config // that can be read, so we can make the map non-nil