Either add a TimeAdd function to the template's FuncMap, or use a constant:
  
    {{ $timestamp := .StartsAt.Add 60000000000 }} //10m is 60000000000 ns

2020. június 12., péntek 17:43:56 UTC+2 időpontban Deepika a következőt 
írta:
>
> *Objective:* To subtract 10 minutes from go's time.Time 
> object(".StartsAt") in html template (In specific the prometheus 
> alertmanager's email template: email_template.tmpl)
> *Code: *<tr><td>error_timestamp</td><td>{{ .StartsAt }}</td></tr>
>
> *Alertmanager version*: 0.20.0
>
> *Options tried and corresponding errors :*
>
> 1. <td>{{ .StartsAt.Add(-10*time.Minute) }}</td>  ::::::: Unexpected 
> operand "("
> 2. <td>{{ .StartsAt.Add "-10*time.Minute" }}</td>  :::::::  expected 
> integer; found "-10*time.Minute\""
> 3.  {{ $timestamp := .StartsAt.Add "10m" }} :::::::::::::::: wrong type 
> for value; expected time.Duration; got string
> 4.  {{ $timestamp :=  Add .StartsAt "10m" }} ::::::::::: Add function not 
> defined
> 5.  {{ $timestamp :=  .StartsAt.Add -10*time.Minute }} :::::::::::: time 
> function not defined
> 6.  {{ $timestamp :=  .StartsAt.Add (-10*time.Minute) }} :::::::::::: 
> illegal operand *
> 7.  {{ $timestamp :=  .StartsAt.Add (time.duration "10m") }} :::::::::::: 
> duration function not defined 
> 8. {{ $timestamp :=  .StartsAt.Add (time.ParseDuration "10m") }} 
> ::::::::::::  time function not defined
> 9.  {{ $timestamp :=  .StartsAt.Add 10 }} ::::::::::: No error. But no 
> change in timestamp too.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/158a6140-7916-48c8-909a-33bea557805eo%40googlegroups.com.

Reply via email to