What function would you use to write data to a file in Go?

  • file.Write()
  • os.WriteFile()
  • os.Write()
  • os.Create()
To write data to a file in Go, you would use the os.WriteFile() function. This function takes the file path, the data to write, and the file permissions as parameters. It allows you to create or overwrite a file and write the specified data to it. The os.Create() function can be used to create a new file, but it does not directly write data to it.
Add your answer
Loading...

Leave a comment

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