writers_readers/

directory
v0.0.0-...-7bfcdb5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2015 License: Apache-2.0

README

Writers/Readers - Standard Library

The ability to stream and pass data around is incredibility important. Data is constantly coming at our programs whether over a socket, file, device, etc. Many times this data needs to just be moved from one stream. Sometimes it needs to be encrypted, hashed or stored for safe keeping. The Writer and Reader interfaces may be the most heavily used and supported interfaces in both the standard library and the community.

Notes

  • The standard library provides all the infrastructure we need to stream and work with data.
  • If we implement the Reader and Writer interfaces in our own types, we get this functionality for free.
  • Implementing interfaces to existing functionality saves us from both development time and bugs.

Documentation

Interface Declarations

http://golang.org/pkg/io/

Code Review

Standard Library Working Together (Go Playground)

Simple curl with io.Reader and io.Writer (Go Playground)

MultiWriters with curl example (Go Playground)

Advanced Code Review

TeeReader and io composition (Go Playground)

Gzip and Md5 support with curl example (Go Playground)

Exercises

Exercise 1

Download any document from the web and display the content in the terminal and write it to a file at the same time.

Template (Go Playground) | Answer (Go Playground)


All material is licensed under the Apache License Version 2.0, January 2004.

Directories

Path Synopsis
advanced
example1
Sample program to show how io.Writes can be embedded within other Writer calls to perform complex writes.
Sample program to show how io.Writes can be embedded within other Writer calls to perform complex writes.
example2
Sample program that adds a few more features.
Sample program that adds a few more features.
Sample program to show how different functions from the standard library use the io.Writer interface.
Sample program to show how different functions from the standard library use the io.Writer interface.
Sample program to show how to write a simple version of curl using the io.Reader and io.Writer interface support.
Sample program to show how to write a simple version of curl using the io.Reader and io.Writer interface support.
Sample program to show how to use a MultiWriter to perform writes to multiple devices with one write call.
Sample program to show how to use a MultiWriter to perform writes to multiple devices with one write call.
exercises
exercise1
Download any document from the web and display the content in the terminal and write it to a file at the same time.
Download any document from the web and display the content in the terminal and write it to a file at the same time.
template1
Download any document from the web and display the content in the terminal and write it to a file at the same time.
Download any document from the web and display the content in the terminal and write it to a file at the same time.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL