Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning Functional Programming in Go

You're reading from   Learning Functional Programming in Go Change the way you approach your applications using functional programming in Go

Arrow left icon
Product type Paperback
Published in Nov 2017
Publisher Packt
ISBN-13 9781787281394
Length 670 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Lex Sheehan Lex Sheehan
Author Profile Icon Lex Sheehan
Lex Sheehan
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Pure Functional Programming in Go 2. Manipulating Collections FREE CHAPTER 3. Using High-Order Functions 4. SOLID Design in Go 5. Adding Functionality with Decoration 6. Applying FP at the Architectural Level 7. Functional Parameters 8. Increasing Performance Using Pipelining 9. Functors, Monoids, and Generics 10. Monads, Type Classes, and Generics 11. Category Theory That Applies 12. Miscellaneous Information and How-Tos

Getting the source code

The GitHub repository for this book's source code is https://github.com/l3x/learn-fp-go.

If you store your Go projects in the ~/myprojects directory, then run cd ~/myprojects; git clone https://github.com/l3x/learn-fp-go.git.

Next, run the cd command into the first project directory: cd ~/myprojects/learn-fp-go/1-functional-fundamentals/ch01-pure-fp/01_oop.

The directory structure of the source files

Directories correspond to the book's units and chapters:

You'll find an executable init script file in all project directories. It's there to make your life easier. When you cd into a project directory, first source the init script. You can do that by either typing source init or . init . (The dot (.) and source commands are interchangeable.) The init script will use Glide to install any dependencies for your project in a vendors directory.
For details see the How to build and run Go project section in the Appendix, Miscellaneous Information and How-Tos.
PS: Dependencies are third-party Go libraries that our Go application needs to run properly. 

Let's run our first Go application as follows:

Each chapter is divided into sequentially numbered directories that are in the order of their appearance in the book.

How to run our first Go application

First, let's make sure we have Go installed, our GOPATH is properly set, and that we can run a Go application.

If you are using a macOS, then check out the instructions on how to use the brew command to install Go in the appendix; otherwise, to install Go, visit: http://golang.org/doc/install. To set your GOPATH, visit: https://github.com/golang/go/wiki/SettingGOPATH.

Many people use a global GOPATH to store the source code for all their Go applications or, frequently, manually reset their GOPATH. I found this practice to be troublesome when working with multiple Go projects for multiple clients, each of which had differing Go versions and third-party dependencies.

The example Go applications that we'll use in this chapter do not have dependencies; that is, we don't have to import any third-party packages. So, all we have to do to run our first app--cars.go--is verify that Go is installed, set our GOPATH, and type go run cars.go:

Using a global GOPATH is easy for projects that are super simple, like the examples in this chapter.

In Chapter 2, Manipulating Collections, our Go applications will start getting more complex, and we'll get introduced to a simple, more consistent way to manage our Go development environments.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime