Standard library / html/template
html/template.Srcset
Trusted srcset attribute content; use only validated developer-controlled values. Expected stdout: '<img srcset="/a.png 1x, /b.png 2x">\n'.
Formal Syntax & Structure
go syntaxgo
type Srcset stringWorking Example
Example Snippetgo
package main
import ( "fmt" "html/template" "os")
func check(e error) { if e != nil { panic(e) }}
func main() { t := template.Must(template.New("x").Parse("<img srcset=\"{{.}}\">")) check(t.Execute(os.Stdout, template.Srcset("/a.png 1x, /b.png 2x"))) fmt.Println()}