@@ -44,18 +44,18 @@ func newTestDialer() *testDialer {
4444// For instance, to test an async logger that have to dial 4 times before succeeding,
4545// the test should look like this:
4646//
47- // d := newTestDialer() // Create a new stubbed dialer
48- // cfg := Config{
49- // Async: true,
50- // // ...
51- // }
52- // f := newWithDialer(cfg, d) // Create a fluent logger using the stubbed dialer
53- // f.EncodeAndPostData("tag_name", time.Unix(1482493046, 0), map[string]string{"foo": "bar"})
47+ // d := newTestDialer() // Create a new stubbed dialer
48+ // cfg := Config{
49+ // Async: true,
50+ // // ...
51+ // }
52+ // f := newWithDialer(cfg, d) // Create a fluent logger using the stubbed dialer
53+ // f.EncodeAndPostData("tag_name", time.Unix(1482493046, 0), map[string]string{"foo": "bar"})
5454//
55- // d.waitForNextDialing(false, false) // 1st dialing attempt fails
56- // d.waitForNextDialing(false, false) // 2nd attempt fails too
57- // d.waitForNextDialing(false, false) // 3rd attempt fails too
58- // d.waitForNextDialing(true, false) // Finally the 4th attempt succeeds
55+ // d.waitForNextDialing(false, false) // 1st dialing attempt fails
56+ // d.waitForNextDialing(false, false) // 2nd attempt fails too
57+ // d.waitForNextDialing(false, false) // 3rd attempt fails too
58+ // d.waitForNextDialing(true, false) // Finally the 4th attempt succeeds
5959//
6060// Note that in the above example, the logger operates in async mode. As such,
6161// a call to Post, PostWithTime or EncodeAndPostData is needed *before* calling
@@ -66,20 +66,20 @@ func newTestDialer() *testDialer {
6666// case, you have to put the calls to newWithDialer() and to EncodeAndPostData()
6767// into their own goroutine. An example:
6868//
69- // d := newTestDialer() // Create a new stubbed dialer
70- // cfg := Config{
71- // Async: false,
72- // // ...
73- // }
74- // go func() {
75- // f := newWithDialer(cfg, d) // Create a fluent logger using the stubbed dialer
76- // f.Close()
77- // }()
69+ // d := newTestDialer() // Create a new stubbed dialer
70+ // cfg := Config{
71+ // Async: false,
72+ // // ...
73+ // }
74+ // go func() {
75+ // f := newWithDialer(cfg, d) // Create a fluent logger using the stubbed dialer
76+ // f.Close()
77+ // }()
7878//
79- // d.waitForNextDialing(false, false) // 1st dialing attempt fails
80- // d.waitForNextDialing(false, false) // 2nd attempt fails too
81- // d.waitForNextDialing(false, false) // 3rd attempt fails too
82- // d.waitForNextDialing(true, false) // Finally the 4th attempt succeeds
79+ // d.waitForNextDialing(false, false) // 1st dialing attempt fails
80+ // d.waitForNextDialing(false, false) // 2nd attempt fails too
81+ // d.waitForNextDialing(false, false) // 3rd attempt fails too
82+ // d.waitForNextDialing(true, false) // Finally the 4th attempt succeeds
8383//
8484// Moreover, waitForNextDialing() returns a *Conn which extends net.Conn to provide testing
8585// facilities. For instance, you can call waitForNextWrite() on these connections, to
@@ -90,24 +90,24 @@ func newTestDialer() *testDialer {
9090//
9191// Here's a full example:
9292//
93- // d := newTestDialer()
94- // cfg := Config{Async: true}
93+ // d := newTestDialer()
94+ // cfg := Config{Async: true}
9595//
96- // f := newWithDialer(cfg, d)
97- // f.EncodeAndPostData("tag_name", time.Unix(1482493046, 0), map[string]string{"foo": "bar"})
96+ // f := newWithDialer(cfg, d)
97+ // f.EncodeAndPostData("tag_name", time.Unix(1482493046, 0), map[string]string{"foo": "bar"})
9898//
99- // conn := d.waitForNextDialing(true, false) // Accept the dialing
100- // conn.waitForNextWrite(false, "") // Discard the 1st attempt to write the message
99+ // conn := d.waitForNextDialing(true, false) // Accept the dialing
100+ // conn.waitForNextWrite(false, "") // Discard the 1st attempt to write the message
101101//
102- // conn := d.waitForNextDialing(true, false)
103- // assertReceived(t, // t is *testing.T
104- // conn.waitForNextWrite(true, ""),
105- // "[\"tag_name\",1482493046,{\"foo\":\"bar\"},{}]")
102+ // conn := d.waitForNextDialing(true, false)
103+ // assertReceived(t, // t is *testing.T
104+ // conn.waitForNextWrite(true, ""),
105+ // "[\"tag_name\",1482493046,{\"foo\":\"bar\"},{}]")
106106//
107- // f.EncodeAndPostData("something_else", time.Unix(1482493050, 0), map[string]string{"bar": "baz"})
108- // assertReceived(t, // t is *testing.T
109- // conn.waitForNextWrite(true, ""),
110- // "[\"something_else\",1482493050,{\"bar\":\"baz\"},{}]")
107+ // f.EncodeAndPostData("something_else", time.Unix(1482493050, 0), map[string]string{"bar": "baz"})
108+ // assertReceived(t, // t is *testing.T
109+ // conn.waitForNextWrite(true, ""),
110+ // "[\"something_else\",1482493050,{\"bar\":\"baz\"},{}]")
111111//
112112// In this example, the 1st connection dialing succeeds but the 1st attempt to write the
113113// message is discarded. As the logger discards the connection whenever a message
@@ -303,7 +303,8 @@ func Test_New_itShouldUseUnixDomainSocketIfUnixSocketSpecified(t *testing.T) {
303303
304304 f , err := New (Config {
305305 FluentNetwork : network ,
306- FluentSocketPath : socketFile })
306+ FluentSocketPath : socketFile ,
307+ })
307308 if err != nil {
308309 t .Error (err )
309310 return
@@ -316,7 +317,8 @@ func Test_New_itShouldUseUnixDomainSocketIfUnixSocketSpecified(t *testing.T) {
316317 network = "unixxxx"
317318 fUnknown , err := New (Config {
318319 FluentNetwork : network ,
319- FluentSocketPath : socketFile })
320+ FluentSocketPath : socketFile ,
321+ })
320322 if _ , ok := err .(* ErrUnknownNetwork ); ! ok {
321323 t .Errorf ("err type: %T" , err )
322324 }
@@ -342,12 +344,12 @@ func Test_MarshalAsMsgpack(t *testing.T) {
342344 f := & Fluent {Config : Config {}}
343345
344346 tag := "tag"
345- var data = map [string ]string {
347+ data : = map [string ]string {
346348 "foo" : "bar" ,
347- "hoge" : "hoge" }
349+ "hoge" : "hoge" ,
350+ }
348351 tm := time .Unix (1267867237 , 0 )
349352 result , err := f .EncodeData (tag , tm , data )
350-
351353 if err != nil {
352354 t .Error (err )
353355 }
@@ -375,7 +377,6 @@ func Test_SubSecondPrecision(t *testing.T) {
375377 encodedData , err := fluent .EncodeData ("tag" , timestamp , map [string ]string {
376378 "foo" : "bar" ,
377379 })
378-
379380 // Assert no encoding errors and that the timestamp has been encoded into
380381 // the message as expected.
381382 if err != nil {
@@ -394,12 +395,12 @@ func Test_SubSecondPrecision(t *testing.T) {
394395func Test_MarshalAsJSON (t * testing.T ) {
395396 f := & Fluent {Config : Config {MarshalAsJSON : true }}
396397
397- var data = map [string ]string {
398+ data : = map [string ]string {
398399 "foo" : "bar" ,
399- "hoge" : "hoge" }
400+ "hoge" : "hoge" ,
401+ }
400402 tm := time .Unix (1267867237 , 0 )
401403 result , err := f .EncodeData ("tag" , tm , data )
402-
403404 if err != nil {
404405 t .Error (err )
405406 }
@@ -477,7 +478,10 @@ func TestPostWithTime(t *testing.T) {
477478 _ = f .PostWithTime ("tag_name" , time .Unix (1482493046 , 0 ), map [string ]string {"foo" : "bar" })
478479 _ = f .PostWithTime ("tag_name" , time .Unix (1482493050 , 0 ), map [string ]string {"fluentd" : "is awesome" })
479480 _ = f .PostWithTime ("tag_name" , time .Unix (1634263200 , 0 ),
480- struct {Welcome string `msg:"welcome"` ; cannot string }{"to use" , "see me" })
481+ struct {
482+ Welcome string `msg:"welcome"`
483+ cannot string
484+ }{"to use" , "see me" })
481485 }()
482486
483487 conn := d .waitForNextDialing (true , false )
0 commit comments