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

The decorator/requestor.go file

The DEBUG output leads us to our last go source file, namely requestor.go:

package decoratorimport (       "io"       "io/ioutil"       "net/http"       "os"       "os/signal"       "sync"       "syscall"       "time")type response struct {       duration      time.Duration       err           error}

The response struct is used to record the duration and any error from running our request. When we capitalize names of symbols, for example, the "J" in our struct named Job in the following code, we are telling Go to export it. When we import a package we will only be able to access exported symbols.

type Job struct {       Client       Client       NumRequests  int       Request      *http.Request       IntervalSecs int       responseChan chan *response}

The private field, responses, is a channel of response pointers with a ...

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