-
Notifications
You must be signed in to change notification settings - Fork 7
logWriter
should buffers unwritten bytes
#16
Conversation
@nishitaniyuki |
logger_test.go
Outdated
type testFormat struct { | ||
} | ||
|
||
func (f *testFormat) String() string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
空 struct の場合ポインタ受けする必要もないので、
func (f testFormat) String() string
で良いです。下も。
logger_test.go
Outdated
l := NewLogger() | ||
output := new(bytes.Buffer) | ||
l.SetOutput(output) | ||
l.SetFormatter(&testFormat{}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l.SetFormatter(testFormat{})
logger_test.go
Outdated
t.Fatal(err) | ||
} | ||
actual := output.Bytes() | ||
if bytes.Compare(actual, tc.Expected) != 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ストレートに bytes.Equal
があります。
https://golang.org/pkg/bytes/#Equal
logger_test.go
Outdated
} | ||
actual := output.Bytes() | ||
if bytes.Compare(actual, tc.Expected) != 0 { | ||
t.Errorf("actual: %s, expected: %s\n", string(actual), string(tc.Expected)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
\n
いるかな?不要な気が。
LTGM. Thank you! |
logWriter.Write
Logger.Writer