The Secret Life of Go: Interfaces in Practice
The Secret Life of Go: Interfaces in Practice # go # coding # programming # softwaredevelopment How to replace three redundant functions with one io.Reader . Chapter 18: The Universal Adapter The archive was quiet, except for the rhythmic thrum-click of the pneumatic tube system delivering requests to the front desk. Ethan had his headphones on, typing furiously. "You are typing very fast," Eleanor observed, pausing at his desk with a cart full of magnetic tapes. "That usually means you are copying and pasting." Ethan pulled off his headphones, looking guilty. "I'm building a log analyzer. It needs to read logs from three places: a local file archive, a live HTTP stream from the server, and sometimes just a raw string for testing." He pointed to his code. "I wrote three functions." // 1. Read from a file func AnalyzeFile ( filename string ) error { f , err := os . Open ( filename ) if err != nil { return e...