Implement the following plan:
Port of the Ruby changelog-parser gem as a Go library module at github.com/git-pkgs/changelog, following the same patterns as purl, vers, and spdx.
Parses changelog files (Keep a Changelog, markdown headers, setext/underline style) into structured entries with version, date, and content. Supports auto-detection of format, custom regex patterns, version lookup, and extracting content between versions.
All under /Users/andrew/code/git-pkgs/changelog/:
go.modmodule github.com/git-pkgs/changelog go 1.25.6
No external dependencies needed.
changelog.goPackage docs and primary API. Exported types:
Exported functions:
Parse(content string) *Parser - create parser with auto-detectionParseWithFormat(content string, format Format) *Parser - explicit formatParseWithPattern(content string, pattern *regexp.Regexp) *Parser - custom regexParseFile(path string) (*Parser, error) - parse a fileFindChangelog(directory string) (string, error) - find changelog file in dirFindAndParse(directory string) (*Parser, error) - find + parseParser methods:
Versions() []string - ordered version listEntry(version string) (Entry, bool) - get single entryEntries() map[string]Entry - all entries (ordered map via slice internally)Between(oldVersion, newVersion string) (string, bool) - content between two versionsLineForVersion(version string) int - line number of version header (-1 if not found)Use an internal ordered representation (slice of version+entry pairs) to preserve insertion order, since Go maps don't.
changelog_test.goTable-driven tests using testing package. Port all test cases from the Ruby gem:
testdata/Copy the four fixture files from the Ruby gem:
testdata/keep_a_changelog.mdtestdata/markdown_header.mdtestdata/underline.mdtestdata/comprehensive.mdDirect ports of the Ruby patterns:
cd /Users/andrew/code/git-pkgs/changelog && go test ./... - all tests passgo vet ./... - no issuesIf you need specific details from before exiting plan mode (like exact code snippets, error messages, or content you generated), read the full transcript at: /Users/andrew/.claude/projects/-Users-andrew-code-git-pkgs/fc727ae6-4584-4a0e-8e60-0c9d705c7c17.jsonl
I'll start by examining the existing sibling packages for patterns and the Ruby gem for the logic to port.
Now let me read the actual Ruby source files and fixtures to get exact content for porting.
Now let me look at the vers package for LICENSE, workflow files, and README patterns.
Now let me check if there's a zizmor config in any of the other packages.
Good. Now I have everything I need. Let me create the changelog directory and all the files.
Now the workflow files:
Now the test fixture files:
Now the main library file:
Now the test file:
Let me run the tests to see where we stand.
Two issues to fix:
(?<!...)), need a different approach for LineForVersionFindAllStringSubmatchIndex and multiline - the ^ anchor needs (?m) flagLet me fix both:
Now fix the custom pattern issue - the patterns in the tests use ^ but need multiline mode to work with FindAllStringSubmatchIndex:
The v prefix test is failing because ## v1.0.0 - after stripping the v, we search for 1.0.0 in the line ## v1.0.0. The versionLineRe pattern ^v?1\.0\.0:?\s won't match because it doesn't start with v?1.0.0 - it starts with ##. And the # prefix check does match, but the initial char-before-match check fails because the char before 1.0.0 is v which is a word char. I need to also try matching with the v prefix in the line.
All 38 tests pass. Now let me run go vet:
Clean. Now let me write the README and set up the git repo. Let me also remove the unused dateOf helper from the test file:
Now write the README:
Let me also fix the lint diagnostic about slices.Contains:
I need to also fix the closing brace:
Looks correct. Let me run tests again:
All 38 tests pass, go vet clean. Now let me initialize the git repo, set it up with the remote, commit, and push.
Done. Here's what was created at github.com/git-pkgs/changelog:
Library (changelog.go) - 430 lines porting the Ruby gem's parsing logic:
Parse, ParseWithFormat, ParseWithPattern, ParseFile, FindChangelog, FindAndParse constructorsVersions(), Entry(), Entries(), Between(), LineForVersion() methodsTests (changelog_test.go) - 38 tests covering all Ruby gem test cases: format detection, all three formats with fixtures, custom patterns, Between method, LineForVersion edge cases (substring avoidance, range avoidance, v-prefix), prerelease/build metadata, markdown preservation, and the comprehensive fixture.
Infrastructure - CI workflow matching vers (Go 1.25, build/test/lint), zizmor workflow, MIT license, .gitignore, and README with usage examples.
if ci passes, tag it v0.1.0
CI failed. Let me check what went wrong.
Lint errcheck on an unchecked os.WriteFile in the test. Quick fix:
Now let me wait for CI to finish.
CI passed. Tagging v0.1.0.
Tagged and pushed v0.1.0.
go mod tidy
No changes - go.mod was already tidy (no dependencies to resolve).
can we update the org readme for git-pkgs to list all the modules we have now (don't push until reviewed)
I see the current list. Let me also check which of these repos are actually public/library modules vs internal tools, so I only add what belongs.
Here's the diff:
Added changelog in alphabetical order with the other libraries. Ready for you to review before committing/pushing.
i feel like there might be others missing
Let me check which repos are actually public on the org.
Comparing against what's currently listed, these public library repos are missing:
Six missing libraries added (archives, changelog, enrichment, forges, gitignore, platforms, vulns), all alphabetical. I left out non-library repos like resolve, proxy, website, demo, testing, homebrew-git-pkgs, and packageurl-go since the section is titled "Libraries". Ready when you want to commit.
we probably don't need to say "go library" for each one
Ready for review.
commit abd push
Remote is ahead. Let me pull and retry.
Pushed.
good, is there anything like scancode license and copyright detection in go out there?
A few options, though nothing as complete as scancode:
google/licensecheck is probably the closest to what you want. It's a library (not just a CLI) that classifies license text by matching against known licenses. Used internally by the Go module proxy for license detection on pkg.go.dev. No copyright detection though.
go-license-detector from source{d} does file-level license detection using TF-IDF similarity against SPDX license texts. Good accuracy but the repo hasn't been maintained since ~2020 (source{d} folded).
IBM/license-scanner matches against SPDX license templates and has some copyright/keyword detection support. More active than go-license-detector.
jfrog/go-license-discovery is another matching library, from JFrog.
google/go-licenses and mitchellh/golicense are CLIs for scanning Go module dependencies specifically, not general-purpose file scanners.
None of them do copyright holder extraction the way scancode does. If you need both license and copyright detection in Go, you'd likely end up wrapping scancode or porting parts of it. Were you thinking of building something for git-pkgs?
any REUSE modules in go?
Doesn't look like it. The REUSE tool itself is Python, and I couldn't find a Go library that implements the REUSE spec (checking for SPDX headers in every file, .reuse/dep5 parsing, REUSE.toml, etc.).
The closest things in Go are tangential:
If you wanted REUSE compliance checking as a Go library you'd be building it from scratch. The spec itself isn't huge though -- it's mostly about finding SPDX-License-Identifier/SPDX-FileCopyrightText tags in files, falling back to .license sidecar files, and parsing REUSE.toml or .reuse/dep5. Were you thinking about adding REUSE support to git-pkgs?
Sources:
ok yes lets make a reuse library in go, i've created a folder for it, it needs to be fully spec driven, ideally has the spec as a submodule for testing