RESTful resources

Let's open http://localhost:8000/cars to see the full list of cars from both cars.csv and more_cars.csv:

Let's take a look at the next Filter function in action in main.go:

PrintCars("Numeric", cars.Filter(ByHasNumber()))

You will see the following output:

Numeric
-----------------------
car: Honda Accord ES2
car: Lexus IS250
car: Lexus SC 430
car: Ford F-150
car: Toyota 86
car: Toyota RAV4
car: GM Hummer H2
car: GM Hummer H3

The FilterFunc method used in this case is ByHasNumber(). It operates like ByMake FilterFunc and uses Go's regexp MatchString function to return true if the car has a number in it:

func ByHasNumber() FilterFunc {
return func(car string) bool {
match, _ := regexp.MatchString(".+[0-9].*", car)
return match
}
}