Skip to content

linyows/go-onigmo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

91 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

👹 Onigmo bindings for Go

It binds the regular expression library Onigmo to Go.

Travis Codecov GitHub release GoDoc MIT License

Benchmarks

These are the benchmarks as they are defined in Go's regexp package.

$ go test -bench RE2 | sed 's/RE2/Regexp/' > before
$ go test -bench Onigmo | sed 's/Onigmo/Regexp/' > after
$ benchcmp before after
benchmark             old ns/op     new ns/op     delta
BenchmarkRegexp-4     25775         31043         +20.44%

Usage

func main() {
  s := "Hello World"
  re := MustCompile("^Hello (?<word>[A-z]*)$")
  re.MatchString(s)
  word, _ := re.matchResult.Get("word")
  fmt.Sprintf("Naruhodo! The %s", word)

  defer re.matchResult.Free()
  defer re.Free()
}

Installation

$ git clone git@github.com:linyows/go-onigmo.git && cd go-onigmo
$ make onigmo

To install, use go get:

$ go get -d github.com/linyows/go-onigmo

Contribution

  1. Fork (https://github.com/linyows/go-onigmo/fork)
  2. Create a feature branch
  3. Commit your changes
  4. Rebase your local changes against the master branch
  5. Run test suite with the go test ./... command and confirm that it passes
  6. Run gofmt -s
  7. Create a new Pull Request

Author

linyows