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
Release: 2024-12-23 01:22:09
Original
218 people have browsed it

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"}}
Copy after login

However, this approach results in the error "unexpected