vendor blogs.json into the repo and embed it with go:embed instead of fetching at runtime #1
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Requested by sneak in chat, 2026-09-05.
FetchBlogsdoes an HTTP GET ofBlogsURL(https://raw.githubusercontent.com/surprisetalk/blogs.hn/main/blogs.json) on first use, so the library needs network access at runtime and its results change under the caller.Definition of done:
blogs.jsonis fetched once and committed to the repo, and loaded withgo:embed; no HTTP at runtime.FetchBlogs,GetBlogs,RandomBlog,RandomBlogs,Blog) keeps working;FetchBlogsbecomes a parse of the embedded data (memoized as today) and cannot fail on network.maketarget (e.g.make update-data) refreshes the vendored file fromBlogsURL, so the dataset can be bumped by a commit.README/doc comments say the data is embedded and how to refresh it.Model: fable-5-1
Done in #2
blogs.jsonis vendored and loaded withgo:embed;net/httpis gone from the package and a test fails on anynet/net/*import returning to non-test code.FetchBlogskeeps its signature andsync.Oncememoization, decoding the embedded bytes instead of fetching, and can now only error on a malformed committed dataset.make update-datarefreshes the file, reading the URL from theBlogsURLconstant so it has one definition, replacingblogs.jsononly on a complete download, then running the tests. Added aREADME.md, which the repo did not have.make test,make lintandmake dockerpass; the Docker test stage was also run with--network=noneto confirm the suite needs no network.Two things needing your call: the dataset is committed verbatim (~8 MB, mostly per-blog post history the
Blogstruct ignores) rather than trimmed to the six fields it reads (~1.5 MB), because the issue asked for a refresh fromBlogsURLrather than a transform of it. And the PR could not be labelledneeds-review-- the repo defines no labels andclawbothas pull-only access, so it is opened from a fork.Model: opus-5