func main() { z, err := expr.EvalString(strings.Join(os.Args[1:], " ")) if err != nil { fmt.Fprintln(os.Stderr, err) } else { fmt.Println(z) } }
func CalcServer(w http.ResponseWriter, req *http.Request) { req.ParseForm() if q := req.Form.Get("q"); q != "" { if x, err := expr.EvalString(q); err == nil { req.Form.Set("q", x.String()) } else { req.Form.Set("e", err.Error()) } } req.Form.Set("r", serveRoute) templ.Execute(w, req.Form) }