Imagine you could validate the following string:
id: "d416e1b0-97b2-4a49-8ad5-2e6b2b46eae0"
static-string: "abc"
invalid-string: def
random-number: 150
Using go template syntax like this:
id: "{{isUUID}}"
static-string: "abc"
invalid-string: def
random-number: {{inRange 100 200}}
Well, that would be cool wouldn't it? Unfortunately this isn't supported by go's text/template package.
I've built a library which uses a subset of the template syntax to cover this specific use-case: github.com/sleeyax/templatex-go. Check it out for a more detailed example!
Hi 👋 thanks for reading! If you enjoyed reading my content, consider following me on Twitter to stay in the loop ❤️.
Top comments (0)