[DEV] Zero initialization

This commit is contained in:
Jian Han 2018-04-14 22:41:23 +10:00
parent 5fe2f0aa7f
commit 6240073da1

View File

@ -0,0 +1,27 @@
package main
import (
"fmt"
"os"
)
type Logger struct {
out *os.File
}
func (l Logger) Log(s string) {
out := l.out
if out == nil {
out = os.Stderr
}
fmt.Fprintf(out, "%s [%d]: %s\n", os.Args[0],
os.Getpid(), s)
}
func (l *Logger) SetOutput(out *os.File) {
l.out = out
}
func main() {
l := Logger{}
l.Log("test")
}