Skip to content

Commit 6707d4a

Browse files
committed
all: gofmt code for current go versions
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 38df75e commit 6707d4a

File tree

4 files changed

+40
-38
lines changed

4 files changed

+40
-38
lines changed

README.md

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ fluent-logger-golang
88

99
## How to install
1010

11-
```
12-
go get github.com/fluent/fluent-logger-golang/fluent
11+
```bash
12+
go get github.com/fluent/fluent-logger-golang/fluent@latest
1313
```
1414

1515
## Usage
1616

1717
Install the package with `go get` and use `import` to include it in your project.
1818

19-
```
19+
```go
2020
import "github.com/fluent/fluent-logger-golang/fluent"
2121
```
2222

@@ -26,27 +26,28 @@ import "github.com/fluent/fluent-logger-golang/fluent"
2626
package main
2727

2828
import (
29-
"github.com/fluent/fluent-logger-golang/fluent"
30-
"fmt"
31-
//"time"
29+
"fmt"
30+
// "time"
31+
32+
"github.com/fluent/fluent-logger-golang/fluent"
3233
)
3334

3435
func main() {
35-
logger, err := fluent.New(fluent.Config{})
36-
if err != nil {
37-
fmt.Println(err)
38-
}
39-
defer logger.Close()
40-
tag := "myapp.access"
41-
var data = map[string]string{
42-
"foo": "bar",
43-
"hoge": "hoge",
44-
}
45-
error := logger.Post(tag, data)
46-
// error := logger.PostWithTime(tag, time.Now(), data)
47-
if error != nil {
48-
panic(error)
49-
}
36+
logger, err := fluent.New(fluent.Config{})
37+
if err != nil {
38+
fmt.Println(err)
39+
}
40+
defer logger.Close()
41+
tag := "myapp.access"
42+
data := map[string]string{
43+
"foo": "bar",
44+
"hoge": "hoge",
45+
}
46+
error := logger.Post(tag, data)
47+
// error = logger.PostWithTime(tag, time.Now(), data)
48+
if error != nil {
49+
panic(error)
50+
}
5051
}
5152
```
5253

@@ -181,7 +182,7 @@ were involved. Starting v1.8.0, the logger no longer accepts `Fluent.Post()`
181182
after `Fluent.Close()`, and instead returns a "Logger already closed" error.
182183

183184
## Tests
184-
```
185185

186+
```bash
186187
go test
187188
```

_examples/main.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"log"
66
"time"
77

8-
"../fluent"
8+
"github.com/fluent/fluent-logger-golang/fluent"
99
)
1010

1111
func main() {
@@ -15,9 +15,10 @@ func main() {
1515
}
1616
defer logger.Close()
1717
tag := "myapp.access"
18-
var data = map[string]string{
18+
data := map[string]string{
1919
"foo": "bar",
20-
"hoge": "hoge"}
20+
"hoge": "hoge",
21+
}
2122
for i := 0; i < 100; i++ {
2223
e := logger.Post(tag, data)
2324
if e != nil {

fluent/fluent.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package fluent
22

33
import (
4+
"bytes"
45
"context"
56
"crypto/tls"
7+
"encoding/base64"
8+
"encoding/binary"
69
"encoding/json"
710
"errors"
811
"fmt"
@@ -16,10 +19,6 @@ import (
1619
"sync/atomic"
1720
"time"
1821

19-
"bytes"
20-
"encoding/base64"
21-
"encoding/binary"
22-
2322
"github.com/tinylib/msgp/msgp"
2423
)
2524

fluent/fluent_test.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,8 @@ func Test_New_itShouldUseUnixDomainSocketIfUnixSocketSpecified(t *testing.T) {
311311

312312
f, err := New(Config{
313313
FluentNetwork: network,
314-
FluentSocketPath: socketFile})
314+
FluentSocketPath: socketFile,
315+
})
315316
if err != nil {
316317
t.Error(err)
317318
return
@@ -324,7 +325,8 @@ func Test_New_itShouldUseUnixDomainSocketIfUnixSocketSpecified(t *testing.T) {
324325
network = "unixxxx"
325326
fUnknown, err := New(Config{
326327
FluentNetwork: network,
327-
FluentSocketPath: socketFile})
328+
FluentSocketPath: socketFile,
329+
})
328330
if _, ok := err.(*ErrUnknownNetwork); !ok {
329331
t.Errorf("err type: %T", err)
330332
}
@@ -350,12 +352,12 @@ func Test_MarshalAsMsgpack(t *testing.T) {
350352
f := &Fluent{Config: Config{}}
351353

352354
tag := "tag"
353-
var data = map[string]string{
355+
data := map[string]string{
354356
"foo": "bar",
355-
"hoge": "hoge"}
357+
"hoge": "hoge",
358+
}
356359
tm := time.Unix(1267867237, 0)
357360
result, err := f.EncodeData(tag, tm, data)
358-
359361
if err != nil {
360362
t.Error(err)
361363
}
@@ -383,7 +385,6 @@ func Test_SubSecondPrecision(t *testing.T) {
383385
encodedData, err := fluent.EncodeData("tag", timestamp, map[string]string{
384386
"foo": "bar",
385387
})
386-
387388
// Assert no encoding errors and that the timestamp has been encoded into
388389
// the message as expected.
389390
if err != nil {
@@ -402,12 +403,12 @@ func Test_SubSecondPrecision(t *testing.T) {
402403
func Test_MarshalAsJSON(t *testing.T) {
403404
f := &Fluent{Config: Config{MarshalAsJSON: true}}
404405

405-
var data = map[string]string{
406+
data := map[string]string{
406407
"foo": "bar",
407-
"hoge": "hoge"}
408+
"hoge": "hoge",
409+
}
408410
tm := time.Unix(1267867237, 0)
409411
result, err := f.EncodeData("tag", tm, data)
410-
411412
if err != nil {
412413
t.Error(err)
413414
}

0 commit comments

Comments
 (0)