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
+29.9k Golang : Get and Set User-Agent examples
+5.4k Golang : fmt.Println prints out empty data from struct
+7.2k Golang : Use modern ciphers only in secure connection
+21.6k Golang : Encrypt and decrypt data with TripleDES
+8.6k Android Studio : Import third-party library or package into Gradle Scripts
+12k Golang : Find and draw contours with OpenCV example
+7.7k Golang : Test if an input is an Armstrong number example
+6.9k Android Studio : Hello World example
+9.2k Golang : Write multiple lines or divide string into multiple lines
+7.4k Golang : How to detect if a sentence ends with a punctuation?
+10.5k Swift : Convert (cast) String to Integer