(#h75wtqq) @xuu@txt.sour.is My layout looks like this:

  • storage/
    • storage.go: defines a Storage interface
    • sqlite.go: implements the Storage interface
    • sqlite_test.go: originally had a function to set up a test storage to test the SQLite storage implementation itself: newRAMStorage(testing.T, $initialData) *Storage
  • controller/
    • feeds.go: uses a Storage
    • feeds_test.go: here I wanted to reuse the newRAMStorage(…) function

I then tried to relocate the newRAMStorage(…) into a

  • teststorage/
    • storage.go: moved here as NewRAMStorage(…)

so that I could just reuse it from both

  • storage/
    • sqlite_test.go: uses testutils.NewRAMStorage(…)
  • controller/
    • feeds_test.go: uses testutils.NewRamStorage(…)

But that results into an import cycle, because the teststorage package imports storage for storage.Storage and the storage package imports testutils for testutils.NewRAMStorage(…) in its test. I’m just screwed. For now, I duplicated it as newRAMStorage(…) in controller/feeds_test.go.

I could put NewRAMStorage(…) in storage/testutils.go, which could be guarded with //go:build testutils. With go test -tags testutils …, in storage/sqlite_test.go could just use NewRAMStorage(…) directly and similarly in controller/feeds_test.go I could call storage.NewRamStorage(…). But I don’t know if I would consider this really elegant.

The more I think about it, the more appealing it sounds. Because I could then also use other test-related stuff across packages without introducing other dedicated test packages. Build some assertions, converters, types etc. directly into the same package, maybe even make them methods of types.

If I went that route, I might do the opposite with the build tag and make it something like !prod instead of testing. Only when building the final binary, I would have to specify the tag to exclude all the non-prod stuff. Hmmm.


#izbp5da

Dang it! I ran into import cycles with shared test utilities again. :-( Either I have to copy this function to set up an in-memory test storage across packages or I have to put it in the storage package itself and guard it with a build tag that is only used in tests (otherwise I end up with this function in my production binary as well). I don’t like any of the alternatives. :-(


#h75wtqq

I went on a 5:30 hours long hike to my second backyard mountain. About 12km to get there and roughly 9km on the way back. It was super nice, sunny all day long, 12°C and luckily just a little bit of wind. Great scenery. I managed to capture one great spotted woodpecker hammering along. There was also a kestrel hovering over a meadow and then landing on a sports field light pole. At the castle ruin I could watch 10-12 gliding red kites (with the V-shaped tail) and other raptors, maybe bussards, I don’t know, for about five minutes. That was fascinating. Unfortunately, my camera doesn’t too well with moving targets.

86 more photos: https://lyse.isobeef.org/wanderung-auf-den-hohenrechberg-2025-03-03/


#ch74qxa

(#jwfdkuq) This seems to be capable of supporting edits as you noted. But I need to think a bit more (~2am here now) of whether this can be abused in any way… The advantage of Content-based Addressing (hashing the content) is that the hash is then immutable, meaning that we can have integrity that the hash actually represents that content from that author at that time.


#6ravbpa

(#jwfdkuq) “`

default_lang = en

discovery_url = https://example.com/discovery/

follow = alice https://example.com/alice.txt ABCDEF12

follow = alice gemini://example.com/alice.txt

avatar = https://example.com/avatar/alice.png

avatar = gemini://example.com/avatar/alice.png

1 2025-03-03T15:00:00-04:00 {lang=en} Hello, world! Welcome to my twtxt feed. UTF-8 check: é, ö, ü.
2 2025-03-03T15:05:00-04:00 {lang=es} ¡Hola, mundo! This tweet is in Spanish.
3 2025-03-03T15:10:00-04:00 {url=ABCDEF12,id=1} Replying to tweet 1 using its URL hash.
4 2025-03-03T15:15:00-04:00 {edited=1} This tweet has been edited once.
5 2025-03-03T15:20:00-04:00 {lang=fr} Bonjour le monde! A French twt overriding the default language.
6 2025-03-03T15:25:00-04:00 Regular twt without metadata defaults to en.
”`


#5hlhjlq