Merge pull request #661 from anant-j/dev

Add Mod operation
This commit is contained in:
Svilen Markov
2025-05-16 17:33:58 +01:00
committed by GitHub
2 changed files with 13 additions and 1 deletions

View File

@@ -414,6 +414,14 @@ func customAPIDoMathOp[T int | float64](a, b T, op string) T {
return 0
}
return a / b
case "mod":
ai, bi := any(a), any(b)
aint, aok := ai.(int)
bint, bok := bi.(int)
if aok && bok && bint != 0 {
return T(aint % bint)
}
return 0
}
return 0
}
@@ -479,6 +487,9 @@ var customAPITemplateFuncs = func() template.FuncMap {
"div": func(a, b any) any {
return doMathOpWithAny(a, b, "div")
},
"mod": func(a, b int) any {
return doMathOpWithAny(a, b, "mod")
},
"now": func() time.Time {
return time.Now()
},