Skip to content

changelog

A Go library for parsing changelog files into structured version entries. Detects format automatically and handles Keep a Changelog, markdown headers, and setext/underline styles.

import "github.com/git-pkgs/changelog"

p := changelog.Parse(content)
for _, v := range p.Versions() {
    entry, _ := p.Entry(v)
    fmt.Printf("%s: %s\n", v, entry.Content)
    if entry.Date != nil {
        fmt.Printf("  Released: %s\n", entry.Date.Format("2006-01-02"))
    }
}

Parsing files

// Parse a specific file
p, err := changelog.ParseFile("CHANGELOG.md")

// Find and parse a changelog in a directory
// Looks for CHANGELOG.md, NEWS, CHANGES, HISTORY, etc.
p, err := changelog.FindAndParse(".")

Getting content between versions

// Get everything between two version headers
content, ok := p.Between("1.0.0", "2.0.0")

Supported formats

FormatExample
Keep a Changelog## [1.0.0] - 2024-01-15
Markdown headers## 1.0.0 (2024-01-15)
Setext/underline1.0.0 followed by =====

Custom patterns are also supported via ParseWithPattern.

Installation

go get github.com/git-pkgs/changelog

View on GitHub