func ImportDir(dir string) {
	contents, err := ioutil.ReadDir(dir)
	if err != nil {
		log.Fatal(err)
	}
	for _, file := range contents {
		if !file.IsDir() {
			contents, err := ioutil.ReadFile(dir + "/" + file.Name())
			if err != nil {
				log.Fatal(err)
			}
			var messages []Message
			err = json.Unmarshal(contents, &messages)
			if err != nil {
				log.Fatal(err)
			}
			for _, message := range messages {
				text := message.Text
				text = parseText(text)
				if text != "" {
					markovChain.Write(text)
				}
			}
		}
	}
}
Handles the import of a channel/directory
package main
import (
	"encoding/json"
	"io/ioutil"
	"log"
)
type Message struct {
	Type string
	User string
	Text string
	TS   string
}
func StartImport(dir *string, channel *string) (err error) {
	log.Printf("Starting import from %s", *dir)
	contents, err := ioutil.ReadDir(*dir)
	if err != nil {
		return err
	}
	_, err = ioutil.ReadFile(*dir + "/users.json")
	if err != nil {
		_, err = ioutil.ReadFile(*dir + "/channel.json")
		if err != nil {
			return err
		}
	}
	go func() {
		for _, file := range contents {
			if file.IsDir() {
				if *channel == "" || *channel == file.Name() {
					ImportDir(*dir + "/" + file.Name())
				}
			}
		}
		err = markovChain.Save(stateFile)
		if err != nil {
			log.Fatal(err)
		}
		log.Printf("Import complete. %d suffixes", len(markovChain.Chain))
	}()
	return nil
}