Ejemplo n.º 1
0
func readConfig() Config {
	var c Config
	if exep, err := osext.ExecutableFolder(); err == nil {
		dir, _ := filepath.Split(strings.TrimSuffix(exep, string(os.PathSeparator)))
		if file, err := ioutil.ReadFile(filepath.Join(dir, "config")); err == nil {
			if err = json.Unmarshal(file, &c); err == nil {
				return c
			}
		}
	}
	// Ugly, but we have to eat an error here. It is to early to properly report what is going on,
	// so all configuration values should behave properly when not initialized
	return Config{}
}
Ejemplo n.º 2
0
func init() {
	exep, _ := osext.ExecutableFolder()
	p := filepath.Join(exep, "test\\cc.db")

	dbDSNro = fmt.Sprintf(dsnPattern, p, "ro")
	dbDSNrw = fmt.Sprintf(dsnPattern, p, "rw")

	fsPath = filepath.Join(exep, "test\\documents", config.RelRoot)
	if !strings.HasSuffix(fsPath, string(os.PathSeparator)) {
		fsPath = fsPath + string(os.PathSeparator)
	}

	dbPath = filepath.ToSlash(filepath.Join("/mnt/us/documents", config.RelRoot))
	if !strings.HasSuffix(dbPath, string(os.PathSeparator)) {
		dbPath = dbPath + string(os.PathSeparator)
	}
	dbPath = filepath.ToSlash(dbPath)
}