(w io.Writer, key, val string)
| 24 | } |
| 25 | |
| 26 | func Log(w io.Writer, key, val string) { |
| 27 | b := bufPool.Get().(*bytes.Buffer) |
| 28 | b.Reset() |
| 29 | // Replace this with time.Now() in a real logger. |
| 30 | b.WriteString(timeNow().UTC().Format(time.RFC3339)) |
| 31 | b.WriteByte(' ') |
| 32 | b.WriteString(key) |
| 33 | b.WriteByte('=') |
| 34 | b.WriteString(val) |
| 35 | _, _ = w.Write(b.Bytes()) |
| 36 | bufPool.Put(b) |
| 37 | } |
| 38 | |
| 39 | func TestPool(t *testing.T) { |
| 40 | go Log(os.Stdout, "path", "search1 \n") |