package main import ( "errors" "log" "os" "git.red-green.com/david/dmmo" ) func main() { var ( idx *dmmo.Index err error ) idx, err = dmmo.LoadIndex("index") if err != nil { if errors.Is(err, os.ErrNotExist) { idx = dmmo.NewIndex() idx.Set("void", "", "BLA ON BLA") idx.Set("player", "@", "GRE ON BLA") idx.Set("player-neutral", "@", "WHI ON BLA") idx.Set("player-ally", "@", "CYA ON BLA") idx.Set("player-enemy", "@", "MAG ON BLA") idx.Set("grass", ".", "GRE ON BLA") idx.Set("stone", ".", "WHI ON BLA") idx.Set("wall-stone-vertical", "|", "WHI ON BLA") idx.Set("wall-stone-horizontal", "-", "WHI ON BLA") idx.Set("door-closed", "+", "BRO ON BLA", false) idx.Set("door-opened", "-", "BRO ON BLA", false) err := idx.Save("index") if err != nil { log.Panicln(err) } } } }