Reading and Writing Files with Slices
This lesson explains in detail how to use a slice for reading and writing to files.
We'll cover the following...
We'll cover the following...
Slices provide the standard-Go way to handle I/O buffers; they are used in the following second version of the function cat, which reads a file in an infinite for-loop (until end-of-file EOF) in a sliced buffer, and writes it to standard output.
Look at the following example:
Welcome to Educative
Click the RUN button, and wait for the terminal to start. Type go run main.go test.txt and press ENTER.
This program is mostly the ...