Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // The file.Read() function will happily read a tiny file in to a large
- // byte slice, but io.ReadFull() will return an
- // error if the file is smaller than the byte slice.
- byteSlice := make([]byte, 2)
- numBytesRead, err := io.ReadFull(file, byteSlice)
- if err != nil {
- log.Fatal(err)
- }
- log.Printf("Number of bytes read: %d\n", numBytesRead)
- log.Printf("Data read: %s\n", byteSlice)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement