Convert back byte array into file using golang
12,417
Sounds like you just want the ioutil.WriteFile
function from the standard library.
https://golang.org/pkg/io/ioutil/#WriteFile
It would look something like this:
permissions := 0644 // or whatever you need
byteArray := []byte("to be written to a file\n")
err := ioutil.WriteFile("file.txt", byteArray, permissions)
if err != nil {
// handle error
}
Author by
Shailesh
Updated on July 28, 2022Comments
-
Shailesh almost 2 years
Is there a way to write a byte array to a file? I have the file name and file extension(like temp.xml).