Functional Programming in Go (Golang)
300 pages
English
PDF
4.5

Functional Programming in Go (Golang)

Functional Programming in Go (Golang)

Author:

Year:

Summary:

The book "Functional Programming in Go (Golang)" is a practical guide that shows how to apply the principles of functional programming (FP) in the imperative language Go. Unlike Haskell or Scala, Go is not a purely functional language, but its powerful features — closures, higher-order functions, interfaces, and strong typing — allow you to effectively implement FP idioms to create reliable and easily maintainable code.



The book is intended for intermediate and advanced Go developers who want to go beyond standard OOP approaches and learn to write more concise, predictable, and testable code. Basic knowledge of Go syntax is required, but experience in functional programming is not — all concepts are introduced from scratch.



What you will learn:

  • FP basics in Go: pure functions, data immutability, absence of side effects.
  • Closures and higher-order functions: how to create function factories, currying, and composition.
  • Working with collections: implementing map, filter, reduce without loops, using generics (Go 1.18+).
  • Monads and functors: practical examples of Maybe, Either, and IO monads for error handling and working with external data.
  • Lazy evaluation and infinite sequences: performance optimization through deferred operations.
  • Testing and debugging: how FP simplifies unit testing and makes code self-documenting.
  • Real-world projects: developing a REST API, a config parser, and a data processing pipeline in a functional style.


Each chapter contains Go code that can be run immediately, and exercises to reinforce the material. You will learn to avoid common mistakes (mutating global state, complex nested loops) and build an architecture that is resilient to change.



By the end of the book, you will be able to:

  • Write functions that are easy to combine and reuse.
  • Reduce the number of bugs by eliminating side effects.
  • Apply functional patterns in production Go code.


This book is not abstract theory, but a tool that will make you a more confident and effective Go developer.

Recommendations