A Go port of Underscore.js
git clone [email protected]:moovweb/gvm.git
cd gvm/
vi binscripts/gvm-installer
./binscripts/gvm-installer
source $HOME/.gvm/scripts/gvm
gvm listall
gvm install go1.2.1
gvm use go1.2.1
git clone [email protected]/markmontymark/asserts.git
cd asserts/
go install
git clone [email protected]/markmontymark/underscore-go.git
cd underscore-go/
go test
cd underscore-go/
go test -bench=.
- so far, only a few Array functions are benchmarked, but it's already interesting to see what's fast and what's slow
- Port speed.js to speed_test.go
- Add Bench*() functions for benchmarking
- Add Example*() functions for showing how to use this code
- Export an Underscore Interface interface, to allow different types to provide enumeration, possibly something like C#'s IEnumerable?
-
adapted from arrays_test.go
package main import "fmt" import "underscore" func main () { num := 35 numbers2 := []underscore.T{10, 20, 30, 40, 50} if v := underscore.IndexOf(numbers2, num, func (a underscore.T, b underscore.T) bool { return a.(int) < b.(int)}, true); v == -1 { fmt.Println("35 is not in the list") } }
- Copy the above code in a file, runme.go, and then on the command line,
go run runme.go
- Copy the above code in a file, runme.go, and then on the command line,
See also the wiki page for some comments on my development of underscore-go