From 3f51a159497db5caa091695859d4405d4a0ed698 Mon Sep 17 00:00:00 2001 From: Casper-Mars <50834595+Casper-Mars@users.noreply.github.com> Date: Mon, 6 Sep 2021 22:50:16 +0800 Subject: [PATCH] Fix lint of files in ./contrib/log/fluent (#1432) * fix(transport/http):fix nil problem * fix(contrib/log/fluent):part of #1430,fix ./contrib/log/fluent --- contrib/log/fluent/fluent.go | 32 +++++++++++++++---------------- contrib/log/fluent/fluent_test.go | 2 +- hack/.lintcheck_failures | 1 - 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/contrib/log/fluent/fluent.go b/contrib/log/fluent/fluent.go index 20e728c4f..8f385b594 100644 --- a/contrib/log/fluent/fluent.go +++ b/contrib/log/fluent/fluent.go @@ -102,30 +102,30 @@ type Logger struct { // tcp://127.0.0.1:24224 // unix://var/run/fluent/fluent.sock func NewLogger(addr string, opts ...Option) (*Logger, error) { - options := options{} + option := options{} for _, o := range opts { - o(&options) + o(&option) } u, err := url.Parse(addr) if err != nil { return nil, err } c := fluent.Config{ - Timeout: options.timeout, - WriteTimeout: options.writeTimeout, - BufferLimit: options.bufferLimit, - RetryWait: options.retryWait, - MaxRetry: options.maxRetry, - MaxRetryWait: options.maxRetryWait, - TagPrefix: options.tagPrefix, - Async: options.async, - ForceStopAsyncSend: options.forceStopAsyncSend, + Timeout: option.timeout, + WriteTimeout: option.writeTimeout, + BufferLimit: option.bufferLimit, + RetryWait: option.retryWait, + MaxRetry: option.maxRetry, + MaxRetryWait: option.maxRetryWait, + TagPrefix: option.tagPrefix, + Async: option.async, + ForceStopAsyncSend: option.forceStopAsyncSend, } switch u.Scheme { case "tcp": - host, port, err := net.SplitHostPort(u.Host) - if err != nil { - return nil, err + host, port, err2 := net.SplitHostPort(u.Host) + if err2 != nil { + return nil, err2 } if c.FluentPort, err = strconv.Atoi(port); err != nil { return nil, err @@ -143,7 +143,7 @@ func NewLogger(addr string, opts ...Option) (*Logger, error) { return nil, err } return &Logger{ - opts: options, + opts: option, log: fl, }, nil } @@ -172,4 +172,4 @@ func (l *Logger) Log(level log.Level, keyvals ...interface{}) error { // Close close the logger. func (l *Logger) Close() error { return l.log.Close() -} \ No newline at end of file +} diff --git a/contrib/log/fluent/fluent_test.go b/contrib/log/fluent/fluent_test.go index a352214ff..e42ce1c04 100644 --- a/contrib/log/fluent/fluent_test.go +++ b/contrib/log/fluent/fluent_test.go @@ -115,4 +115,4 @@ func BenchmarkLoggerHelperInfow(b *testing.B) { h.Infow("log", "test") } }) -} \ No newline at end of file +} diff --git a/hack/.lintcheck_failures b/hack/.lintcheck_failures index de970e5d7..5af78ca9c 100644 --- a/hack/.lintcheck_failures +++ b/hack/.lintcheck_failures @@ -11,4 +11,3 @@ ./contrib/registry/kubernetes ./contrib/registry/zookeeper ./contrib/registry/etcd -./contrib/log/fluent