func NewChangelog() *Changelog {
	return &Changelog{Versions: []*Version{}}
}
NewChangelog creates a pristine Changelog.
package changelog
import (
	"fmt"
	"io"
	"os"
	"reflect"
	"strings"
)
type Changelog struct {
	Versions []*Version
}
func (c *Changelog) String() string {
	return join(c.Versions, "\n\n") + "\n"
}
type Version struct {
	Version     string
	Date        string
	History     []*ChangeLine
	Subsections []*Subsection
}
func (v *Version) String() string {
	out := fmt.Sprintf("## %s", v.Version)
	if v.Date != "" {
		out += " / " + v.Date
	}
	if len(v.History) > 0 {
		out += "\n\n" + join(v.History, "\n")
	}
	if len(v.Subsections) > 0 {
		out += "\n\n" + join(v.Subsections, "\n\n")
	}
	return out
}
type Subsection struct {
	Name    string
	History []*ChangeLine
}
func (s *Subsection) String() string {
	if len(s.History) > 0 {
		return fmt.Sprintf(
			"### %s\n\n%s",
			s.Name,
			join(s.History, "\n"),
		)
	}
	return ""
}
type ChangeLine struct {
	Summary string
	Reference string
}
func (l *ChangeLine) String() string {
	if l.Reference == "" {
		return fmt.Sprintf(
			"  * %s",
			l.Summary,
		)
	}
	return fmt.Sprintf(
		"  * %s (%s)",
		l.Summary,
		l.Reference,
	)
}
func join(lines interface{}, sep string) string {
	s := reflect.ValueOf(lines)
	if s.Kind() != reflect.Slice {
		panic("join given a non-slice type")
	}
	ret := make([]string, s.Len())
	for i := 0; i < s.Len(); i++ {
		vals := s.Index(i).MethodByName("String").Call(nil)
		ret[i] = vals[0].String()
	}
	return strings.Join(ret, sep)
}