What function is used to read from a file in Go?

  • file.Read()
  • file.ReadBytes()
  • file.ReadAt()
  • io.ReadFull()
In Go, the file.Read() function is not used to read from a file. The correct option is file.ReadBytes(). This function reads from a file and returns the data as a byte slice. It allows you to read a specific number of bytes or read until a delimiter is encountered. This is a common way to read data from files in Go.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *