Golang io.MultiWriter function example
package io
Golang io.MultiWriter function usage example
package main
import (
"fmt"
"io"
"os"
)
func main() {
writer, _ := os.Create("writer.dat")
writer2, _ := os.Create("writer2.dat")
mWriter := io.MultiWriter(writer, writer2)
data := []byte("Hello World!")
n, err := mWriter.Write(data)
if err == nil {
fmt.Printf("Multi write %d bytes to two files simultaneously.\n", n)
}
}
Output :
Multi write to 12 files simultaneously.
Reference :
Advertisement
Something interesting
Tutorials
+12.8k Swift : Convert (cast) Int or int32 value to CGFloat
+51.1k Golang : Disable security check for HTTPS(SSL) with bad or expired certificate
+17k Golang : How to save log messages to file?
+6.3k WARNING: UNPROTECTED PRIVATE KEY FILE! error message
+7.3k Golang : Calculate how many weeks left to go in a given year
+4.7k Linux/MacOSX : How to symlink a file?
+10.9k Golang : Sieve of Eratosthenes algorithm
+9.4k Golang : Play .WAV file from command line
+35.5k Golang : Smarter Error Handling with strings.Contains()
+8.8k Android Studio : Image button and button example
+13.6k Golang : Get user input until a command or receive a word to stop
+4.7k Javascript : Access JSON data example