Source

go-play / multiplex.go

package main

import (
	"io"
	"log"
	"os"
)

func init() {
	filename := "/tmp/log.out"
	flags := os.O_WRONLY|os.O_APPEND|os.O_CREATE
	if file, err := os.OpenFile(filename, flags, 0666); err != nil {
		log.Fatalf("error: can't open %s (%v)", filename, err)
	} else {
		log.SetOutput(io.MultiWriter(os.Stdout, file))
	}
}


func main() {
	log.Print("MOO")
}