Skip to Content
Learning Functional Programming in Go
book

Learning Functional Programming in Go

by Lex Sheehan
November 2017
Intermediate to advanced
670 pages
17h 35m
English
Packt Publishing
Content preview from Learning Functional Programming in Go

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 ES2car: Lexus IS250car: Lexus SC 430car: Ford F-150car: Toyota 86car: Toyota RAV4car: GM Hummer H2car: 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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Functional Programming

Learning Functional Programming

Jack Widman

Publisher Resources

ISBN: 9781787281394Supplemental Content