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
+8.2k Golang : Find relative luminance or color brightness
+6.3k Unix/Linux : Use netstat to find out IP addresses served by your website server
+6.9k Golang : Fibonacci number generator examples
+30k Golang : How to declare kilobyte, megabyte, gigabyte, terabyte and so on?
+3.7k Java : Random alphabets, alpha-numeric or numbers only string generator
+7.4k Golang : Individual and total number of words counter example
+28.6k Golang : Read, Write(Create) and Delete Cookie example
+18.4k Golang : Logging with logrus
+9.4k Golang : Play .WAV file from command line
+8.9k Golang : GMail API create and send draft with simple upload attachment example
+5.8k Javascript : How to replace HTML inside <div>?
+30.4k Golang : How to redirect to new page with net/http?