func (e *Exporter) Export(showNum int, yyyymmdd int) error {
	from := fmt.Sprintf("%s/%s.log", e.InputRoot, time.Now().Format("20060102"))  
	if yyyymmdd != 0 {
		from = fmt.Sprintf("%s/%d.log", e.InputRoot, yyyymmdd)
	}
	to := fmt.Sprintf("%s/radio-t-%d.html", e.OutputRoot, showNum)
	messages, err := readMessages(from, e.ExporterParams.BroadcastUsers)
	if err != nil {
		return errors.Wrapf(err, "failed to read messages from %s", from)
	}
	fh, err := os.OpenFile(to, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0666)  
	if err != nil {
		return errors.Wrapf(err, "failed to open destination file %s", to)
	}
	defer func() {
		if err := fh.Close(); err != nil {
			log.Printf("[WARN] failed to close %s, %v", fh.Name(), err)
		}
	}()
	h, err := e.toHTML(messages, showNum)
	if err != nil {
		return errors.Wrapf(err, "can't export #%d", showNum)
	}
	if _, err = fh.WriteString(h); err != nil {
		return errors.Wrapf(err, "failed to write HTML to file %s", to)
	}
	log.Printf("[INFO] exported %d lines to %s", len(messages), to)
	return nil
}
Export to html with showNum
package reporter
import (
	"bufio"
	"bytes"
	"encoding/json"
	"fmt"
	"html"
	"html/template"
	"io/ioutil"
	"log"
	"net/url"
	"os"
	"regexp"
	"strings"
	"time"
	"github.com/pkg/errors"
	"github.com/radio-t/super-bot/app/bot"
)
type Exporter struct {
	ExporterParams
	location      *time.Location
	fileRecipient FileRecipient
	storage       Storage
	fileIDToURL map[string]string
}
type ExporterParams struct {
	OutputRoot     string
	InputRoot      string
	TemplateFile   string
	BotUsername    string
	SuperUsers     SuperUser
	BroadcastUsers SuperUser  
}
type SuperUser interface {
	IsSuper(user string) bool
}
type Storage interface {
	FileExists(fileName string) (bool, error)
	CreateFile(fileName string, body []byte) (string, error)
	BuildLink(fileName string) string
	BuildPath(fileName string) string
}
func NewExporter(fileRecipient FileRecipient, storage Storage, params ExporterParams) *Exporter {
	log.Printf("[INFO] exporter with %v", params)
	result := Exporter{
		ExporterParams: params,
		fileRecipient:  fileRecipient,
		storage:        storage,
		fileIDToURL:    map[string]string{},
	}
	location, err := time.LoadLocation("Europe/Moscow")
	if err != nil {
		log.Fatalf("[ERROR] can't load location, error %v", err)
	}
	result.location = location
	return &result
}