@@ -45,18 +45,18 @@ func newTestDialer() *testDialer {
4545// For instance, to test an async logger that have to dial 4 times before succeeding,
4646// the test should look like this:
4747//
48- // d := newTestDialer() // Create a new stubbed dialer
49- // cfg := Config{
50- // Async: true,
51- // // ...
52- // }
53- // f := newWithDialer(cfg, d) // Create a fluent logger using the stubbed dialer
54- // f.EncodeAndPostData("tag_name", time.Unix(1482493046, 0), map[string]string{"foo": "bar"})
48+ // d := newTestDialer() // Create a new stubbed dialer
49+ // cfg := Config{
50+ // Async: true,
51+ // // ...
52+ // }
53+ // f := newWithDialer(cfg, d) // Create a fluent logger using the stubbed dialer
54+ // f.EncodeAndPostData("tag_name", time.Unix(1482493046, 0), map[string]string{"foo": "bar"})
5555//
56- // d.waitForNextDialing(false, false) // 1st dialing attempt fails
57- // d.waitForNextDialing(false, false) // 2nd attempt fails too
58- // d.waitForNextDialing(false, false) // 3rd attempt fails too
59- // d.waitForNextDialing(true, false) // Finally the 4th attempt succeeds
56+ // d.waitForNextDialing(false, false) // 1st dialing attempt fails
57+ // d.waitForNextDialing(false, false) // 2nd attempt fails too
58+ // d.waitForNextDialing(false, false) // 3rd attempt fails too
59+ // d.waitForNextDialing(true, false) // Finally the 4th attempt succeeds
6060//
6161// Note that in the above example, the logger operates in async mode. As such,
6262// a call to Post, PostWithTime or EncodeAndPostData is needed *before* calling
@@ -67,20 +67,20 @@ func newTestDialer() *testDialer {
6767// case, you have to put the calls to newWithDialer() and to EncodeAndPostData()
6868// into their own goroutine. An example:
6969//
70- // d := newTestDialer() // Create a new stubbed dialer
71- // cfg := Config{
72- // Async: false,
73- // // ...
74- // }
75- // go func() {
76- // f := newWithDialer(cfg, d) // Create a fluent logger using the stubbed dialer
77- // f.Close()
78- // }()
70+ // d := newTestDialer() // Create a new stubbed dialer
71+ // cfg := Config{
72+ // Async: false,
73+ // // ...
74+ // }
75+ // go func() {
76+ // f := newWithDialer(cfg, d) // Create a fluent logger using the stubbed dialer
77+ // f.Close()
78+ // }()
7979//
80- // d.waitForNextDialing(false, false) // 1st dialing attempt fails
81- // d.waitForNextDialing(false, false) // 2nd attempt fails too
82- // d.waitForNextDialing(false, false) // 3rd attempt fails too
83- // d.waitForNextDialing(true, false) // Finally the 4th attempt succeeds
80+ // d.waitForNextDialing(false, false) // 1st dialing attempt fails
81+ // d.waitForNextDialing(false, false) // 2nd attempt fails too
82+ // d.waitForNextDialing(false, false) // 3rd attempt fails too
83+ // d.waitForNextDialing(true, false) // Finally the 4th attempt succeeds
8484//
8585// Moreover, waitForNextDialing() returns a *Conn which extends net.Conn to provide testing
8686// facilities. For instance, you can call waitForNextWrite() on these connections, to
@@ -91,24 +91,24 @@ func newTestDialer() *testDialer {
9191//
9292// Here's a full example:
9393//
94- // d := newTestDialer()
95- // cfg := Config{Async: true}
94+ // d := newTestDialer()
95+ // cfg := Config{Async: true}
9696//
97- // f := newWithDialer(cfg, d)
98- // f.EncodeAndPostData("tag_name", time.Unix(1482493046, 0), map[string]string{"foo": "bar"})
97+ // f := newWithDialer(cfg, d)
98+ // f.EncodeAndPostData("tag_name", time.Unix(1482493046, 0), map[string]string{"foo": "bar"})
9999//
100- // conn := d.waitForNextDialing(true, false) // Accept the dialing
101- // conn.waitForNextWrite(false, "") // Discard the 1st attempt to write the message
100+ // conn := d.waitForNextDialing(true, false) // Accept the dialing
101+ // conn.waitForNextWrite(false, "") // Discard the 1st attempt to write the message
102102//
103- // conn := d.waitForNextDialing(true, false)
104- // assertReceived(t, // t is *testing.T
105- // conn.waitForNextWrite(true, ""),
106- // "[\"tag_name\",1482493046,{\"foo\":\"bar\"},{}]")
103+ // conn := d.waitForNextDialing(true, false)
104+ // assertReceived(t, // t is *testing.T
105+ // conn.waitForNextWrite(true, ""),
106+ // "[\"tag_name\",1482493046,{\"foo\":\"bar\"},{}]")
107107//
108- // f.EncodeAndPostData("something_else", time.Unix(1482493050, 0), map[string]string{"bar": "baz"})
109- // assertReceived(t, // t is *testing.T
110- // conn.waitForNextWrite(true, ""),
111- // "[\"something_else\",1482493050,{\"bar\":\"baz\"},{}]")
108+ // f.EncodeAndPostData("something_else", time.Unix(1482493050, 0), map[string]string{"bar": "baz"})
109+ // assertReceived(t, // t is *testing.T
110+ // conn.waitForNextWrite(true, ""),
111+ // "[\"something_else\",1482493050,{\"bar\":\"baz\"},{}]")
112112//
113113// In this example, the 1st connection dialing succeeds but the 1st attempt to write the
114114// message is discarded. As the logger discards the connection whenever a message
@@ -296,7 +296,8 @@ func Test_New_itShouldUseUnixDomainSocketIfUnixSocketSpecified(t *testing.T) {
296296
297297 f , err := New (Config {
298298 FluentNetwork : network ,
299- FluentSocketPath : socketFile })
299+ FluentSocketPath : socketFile ,
300+ })
300301 if err != nil {
301302 t .Error (err )
302303 return
@@ -309,7 +310,8 @@ func Test_New_itShouldUseUnixDomainSocketIfUnixSocketSpecified(t *testing.T) {
309310 network = "unixxxx"
310311 fUnknown , err := New (Config {
311312 FluentNetwork : network ,
312- FluentSocketPath : socketFile })
313+ FluentSocketPath : socketFile ,
314+ })
313315 if _ , ok := err .(* ErrUnknownNetwork ); ! ok {
314316 t .Errorf ("err type: %T" , err )
315317 }
@@ -335,12 +337,12 @@ func Test_MarshalAsMsgpack(t *testing.T) {
335337 f := & Fluent {Config : Config {}}
336338
337339 tag := "tag"
338- var data = map [string ]string {
340+ data : = map [string ]string {
339341 "foo" : "bar" ,
340- "hoge" : "hoge" }
342+ "hoge" : "hoge" ,
343+ }
341344 tm := time .Unix (1267867237 , 0 )
342345 result , err := f .EncodeData (tag , tm , data )
343-
344346 if err != nil {
345347 t .Error (err )
346348 }
@@ -368,7 +370,6 @@ func Test_SubSecondPrecision(t *testing.T) {
368370 encodedData , err := fluent .EncodeData ("tag" , timestamp , map [string ]string {
369371 "foo" : "bar" ,
370372 })
371-
372373 // Assert no encoding errors and that the timestamp has been encoded into
373374 // the message as expected.
374375 if err != nil {
@@ -387,12 +388,12 @@ func Test_SubSecondPrecision(t *testing.T) {
387388func Test_MarshalAsJSON (t * testing.T ) {
388389 f := & Fluent {Config : Config {MarshalAsJSON : true }}
389390
390- var data = map [string ]string {
391+ data : = map [string ]string {
391392 "foo" : "bar" ,
392- "hoge" : "hoge" }
393+ "hoge" : "hoge" ,
394+ }
393395 tm := time .Unix (1267867237 , 0 )
394396 result , err := f .EncodeData ("tag" , tm , data )
395-
396397 if err != nil {
397398 t .Error (err )
398399 }
@@ -472,7 +473,10 @@ func TestPostWithTime(t *testing.T) {
472473 _ = f .PostWithTime ("tag_name" , time .Unix (1482493046 , 0 ), map [string ]string {"foo" : "bar" })
473474 _ = f .PostWithTime ("tag_name" , time .Unix (1482493050 , 0 ), map [string ]string {"fluentd" : "is awesome" })
474475 _ = f .PostWithTime ("tag_name" , time .Unix (1634263200 , 0 ),
475- struct {Welcome string `msg:"welcome"` ; cannot string }{"to use" , "see me" })
476+ struct {
477+ Welcome string `msg:"welcome"`
478+ cannot string
479+ }{"to use" , "see me" })
476480 }()
477481
478482 conn := d .waitForNextDialing (true , false )
@@ -755,10 +759,10 @@ func TestSyncWriteAfterCloseFails(t *testing.T) {
755759 err = f .PostWithTime ("tag_name" , time .Unix (1482493050 , 0 ), map [string ]string {"foo" : "buzz" })
756760
757761 // The event submission must fail,
758- assert .NotEqual (t , err , nil );
762+ assert .NotEqual (t , err , nil )
759763
760764 // and also must keep Fluentd closed.
761- assert .NotEqual (t , f .closed , false );
765+ assert .NotEqual (t , f .closed , false )
762766 }()
763767
764768 conn := d .waitForNextDialing (true , false )
0 commit comments