Computing time/duration in Golang templates

I have a structure that gets rendered via template. e.g.: type Foo struct { Created time.Time … } I pass this value to a template, and I’d like to this rendered see: Created at 2022-11-22 9:50 (0d1h12m34s ago) Displaying the timestamp (and formatting it) is easy enough, but I can’t find a way to calculate… Read More Computing time/duration in Golang templates

Golang template can't access file in embedFS

my golang code arch is as bellow: ├── embeded.go ├── go.mod ├── json │   └── file └── main.go and this is my embede.go code: package main import "embed" //go:embed json/* var templatesFS embed.FS func TemplatesFS() embed.FS { return templatesFS } now in my main.go I can’t access file in json directory: package main import (… Read More Golang template can't access file in embedFS