Home >Backend Development >Golang >How to Capture Go Template Output and Assign it to a Variable?

How to Capture Go Template Output and Assign it to a Variable?

Patricia Arquette
Patricia ArquetteOriginal
2024-12-23 01:22:09254browse

How to Capture Go Template Output and Assign it to a Variable?

Capture or Assign Go Template Output to Variable

Within a Go template, the goal is to emulate the following:

{{$var := template "my-template"}}

However, this approach results in the error "unexpected