Gin print query_time as variable

I want my frontend to display the time a request took to process.

ATM I do it like this:

t_start := time.Now()
t_end := time.Since(t_start)

Then I pass it as a variable to the template.
But since I use Gin and it every time logs everything already with precise times, I would love to get the query time from Gin and pass it to the template.

I want to do this for two reasons:

  1. not making golang do things twice.
  2. having more precise times, as when I compare the times, my own calculated times are a little off and not very precise.
  3. the time for rendering the template is not included.

Is there an easy way like storing gins logger time in a variable, which I can access just right before c.HTML(200, "main.html", p) so I can pass it on as a variable?

Thanks in advance!