Commits

npe committed 98249bb

new Configer interface to allow you to compile in config file handling(or not)

Comments (0)

Files changed (2)

 	candidates []map[string]string
 }
 
-func (l *JsonCfg) ConfigFrom(path string) (err os.Error){
+func (l *JsonCfg) ConfigFrom(path string) (err os.Error) {
 	b, err := ioutil.ReadFile(path)
 	if err != nil {
 		return
 	RegisterServer(l Listener) (err os.Error)
 }
 
-func init() {
-
+type Configer interface {
+	Locale
+	ConfigFrom(path string) os.Error
 }
 
 var locales map[string]Locale
 		log.Print("found ", name)
 		return
 	}
-	if _, err = os.Lstat(name); err == nil {
-		log.Print("doing json")
-		var ok bool
-		loc, ok = locales["json"]
+	if _, err = os.Lstat(name); err != nil {
+		goto BadLocale
+	}
+	for _, l := range locales {
+		cfg, ok := l.(Configer)
 		if !ok {
-			log.Exit("json not configured")
+			continue
 		}
-		
-		js, ok := loc.(*JsonCfg)
-		if !ok {
-			log.Exit("bad json locale configuration")
+		err := cfg.ConfigFrom(name)
+		if err == nil {
+			return
 		}
-		js.ConfigFrom(name)
-		log.Print(loc, " ", js)
-		return
 	}
+BadLocale:
 	err = BadLocaleErr
 	return
 }