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

Example InitLog calls

Here we pass the name of our trace file, called trace-log.txt, which will receive all of the logging output. We don't want Debug information, but we do want Info and Error output:

InitLog("trace-log.txt", ioutil.Discard, os.Stdout, os.Stderr)

This time we pass nil for the name of our trace log file, which tells our logger not to create a trace log file. We do want Debug, Info, and Error data displayed to standard out in our terminal console.

InitLog(nil, os.Stdout, os.Stdout, os.Stderr)

When we specify traceFileName, we'll need to create an io.MultiWriter interface to send the output to two places at the same time:

if len(traceFileName) > 0 {      _ = os.Remove(traceFileName)      file, err := os.OpenFile(traceFileName,      os.O_CREATE ...
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