Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. // The file.Read() function will happily read a tiny file in to a large
  2. // byte slice, but io.ReadFull() will return an
  3. // error if the file is smaller than the byte slice.
  4. byteSlice := make([]byte, 2)
  5. numBytesRead, err := io.ReadFull(file, byteSlice)
  6. if err != nil {
  7. log.Fatal(err)
  8. }
  9. log.Printf("Number of bytes read: %d\n", numBytesRead)
  10. log.Printf("Data read: %s\n", byteSlice)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement