Skip to content
This repository has been archived by the owner on Jul 25, 2018. It is now read-only.

Commit

Permalink
Go fmt, add expr to main
Browse files Browse the repository at this point in the history
  • Loading branch information
Russell Cohen committed Oct 26, 2015
1 parent c87d5f9 commit 5d6bbf1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
14 changes: 7 additions & 7 deletions expr/Expr.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package expr
package expr

import (
"fmt"
"github.com/SumoLogic/sumoshell/util"
"strings"
"os/exec"
"fmt"
"strings"
)

type ExprOperator struct {
lsh string
expr string
lsh string
expr string
output *util.JsonWriter
}

Expand Down Expand Up @@ -38,7 +38,7 @@ func (w ExprOperator) Process(inp map[string]interface{}) {
} else {
s = fmt.Sprintf("%v=\"%v\"", k, v)
}
vars = append(vars, s)
vars = append(vars, s)
}
varStr := strings.Join(vars, ";")
pythonCmd := varStr + "; print " + w.expr
Expand All @@ -55,7 +55,7 @@ func (w ExprOperator) Process(inp map[string]interface{}) {
inp[w.lsh] = numRep
} else {
inp[w.lsh] = strOut
}
}
w.output.Write(inp)
}
}
6 changes: 3 additions & 3 deletions parse/Parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ func findNumExtractions(parseExpression string) int {
}

func regexFromPat(pat string) *regexp.Regexp {
regex := ".*?" + strings.Replace(regexp.QuoteMeta(pat), "\\*", "(.*?)", -1)
regex := ".*?" + strings.Replace(regexp.QuoteMeta(pat), "\\*", "(.*?)", -1)
if strings.HasSuffix(pat, "*") {
regex += "$"

} else {
regex += ".*$"
}
}
return regexp.MustCompile(regex)
}

Expand Down
4 changes: 2 additions & 2 deletions ss/Main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
"github.com/SumoLogic/sumoshell/average"
"github.com/SumoLogic/sumoshell/count"
"github.com/SumoLogic/sumoshell/filter"
"github.com/SumoLogic/sumoshell/expr"
"github.com/SumoLogic/sumoshell/filter"
"github.com/SumoLogic/sumoshell/parse"
"github.com/SumoLogic/sumoshell/sum"
"github.com/SumoLogic/sumoshell/util"
Expand All @@ -20,7 +20,7 @@ func main() {
operators := map[string]Builder{
"parse": parse.Build,
"filter": filter.Build,
"expr": expr.Build,
"expr": expr.Build,
}

aggOperators := map[string]AggBuilder{
Expand Down
1 change: 1 addition & 0 deletions sumo/Main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type AggBuilder func([]string) (util.SumoAggOperator, error)
var operators = map[string]Builder{
"parse": parse.Build,
"filter": filter.Build,
"expr": expr.Build,
}

var aggOperators = map[string]AggBuilder{
Expand Down
2 changes: 1 addition & 1 deletion util/Raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,6 @@ func (writer *JsonWriter) Write(inp map[string]interface{}) {
}
}

func CoerceNumber (v interface{}) (float64, error) {
func CoerceNumber(v interface{}) (float64, error) {
return strconv.ParseFloat(fmt.Sprint(v), 64)
}

0 comments on commit 5d6bbf1

Please sign in to comment.