Today I Learned

Short snippets of things I learn along the way.

Go embed.FS requires a file to exist

· #go #til

embed.FS in Go will fail at compile time if the directory you're embedding is completely empty. You need at least one file (even a .gitkeep) for the embed directive to work. This caught me off guard when setting up new content directories.


Goldmark supports custom inline parsers

· #go #goldmark #til

You can add custom inline parsers to Goldmark by implementing the parser.InlineParser interface with a Trigger() byte and a Parse() function. I used this to add [[wiki-link]] syntax to my blog's knowledge base. The key is setting the priority higher than the default link parser so [[ gets matched before [.