Read a File to String
·
162 words
·
1 minute read
This is a matching post to “Writing to a File” and explains how to simply get the contents of a file as text and print it to screen.
There are different ways to achieve this in Go - all valid. In this guide though we’ve gone for the simple approach. Using ioutil
makes this easy for us by not having to worry about closing files or using buffers. At the cost though of not having flexibility over which parts of the file we need.
|
|