diff --git a/.golangci.yml b/.golangci.yml index 200af7d..fdea97f 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -11,7 +11,7 @@ linters: - typecheck # Like the front-end of a Go compiler, parses and type-checks Go code - unused # Checks Go code for unused constants, variables, functions and types - varcheck # Finds unused global variables and constants - - scopelint # Scopelint checks for unpinned variables in go programs + - exportloopref # - golint # Carry out the stylistic conventions put forth in Effective Go and CodeReviewComments linters-settings: diff --git a/biz/plugins.go b/biz/plugins.go index 016b8fd..be77545 100644 --- a/biz/plugins.go +++ b/biz/plugins.go @@ -41,8 +41,8 @@ func NewPlugins(settings *config.AppSettings) *InOutPlugins { plugins.registerPlugin(plugin.NewStdOutput, settings.Codec) } - for _, addr := range settings.OutputGRPC { - addr, err := extractAddr(addr) + for _, item := range settings.OutputGRPC { + addr, err := extractAddr(item) if err != nil { slog.Fatal("OutputGRPC addr error:%v", err) } diff --git a/http2/processor.go b/http2/processor.go index f69aa5c..0831d68 100644 --- a/http2/processor.go +++ b/http2/processor.go @@ -123,6 +123,7 @@ func (p *Processor) processFrameData(f *FrameBase) { // 设置stream的状态 index := f.StreamID % StreamArraySize stream := hc.Streams[index] + var gzipReader *gzip.Reader // 把protobuf转换为JSON字符串 if len(fd.Data) > 0 && !strings.Contains(stream.Method, "grpc.reflection") { @@ -130,7 +131,7 @@ func (p *Processor) processFrameData(f *FrameBase) { // 开启压缩了 if msg.PayloadFormat == compressionMade { // only support gzip - gzipReader, err := gzip.NewReader(bytes.NewReader(msg.EncodedMessage)) + gzipReader, err = gzip.NewReader(bytes.NewReader(msg.EncodedMessage)) if err != nil { slog.Error("processFrameData, gunzip error:%v", err) return @@ -320,7 +321,7 @@ func (f *PBMessageFinder) FindMethodInput(svcAndMethod string) proto.Message { slog.Fatal("PBMessageFinder.FindMethodInput, addr:%v, error:%v,enable grpc reflection service?", f.addr, err) } - refClient := grpcreflect.NewClient(ctx, reflectpb.NewServerReflectionClient(cc)) + refClient := grpcreflect.NewClientV1Alpha(ctx, reflectpb.NewServerReflectionClient(cc)) descSource := grpcurl.DescriptorSourceFromServer(ctx, refClient) svc, method := parseSymbol(svcAndMethod) dsc, err := descSource.FindSymbol(svc) diff --git a/plugin/input_raw.go b/plugin/input_raw.go index b4816c4..9269a6d 100644 --- a/plugin/input_raw.go +++ b/plugin/input_raw.go @@ -171,10 +171,6 @@ func NewRAWInput(address string) (*RAWInput, error) { } } - if err != nil { - return nil, err - } - i.listenerList = make([]*DeviceListener, 0) for j := 0; j < len(deviceList); j++ { i.listenerList = append(i.listenerList, NewDeviceListener(deviceList[j], i.port, &i)) diff --git a/plugin/output_grpc.go b/plugin/output_grpc.go index 163ab4b..fcbce60 100644 --- a/plugin/output_grpc.go +++ b/plugin/output_grpc.go @@ -28,7 +28,8 @@ func NewGRPCOutput(addr string) *GRPCOutput { slog.Fatal("grpcurl.BlockingDial :%v", err) } // 通过反射获取接口定义 - var refClient *grpcreflect.Client = grpcreflect.NewClient(ctx, reflectpb.NewServerReflectionClient(o.cc)) + // *grpcreflect.Client + var refClient = grpcreflect.NewClientV1Alpha(ctx, reflectpb.NewServerReflectionClient(o.cc)) o.descSource = grpcurl.DescriptorSourceFromServer(ctx, refClient) slog.Info("create grpc output, addr:%v", addr)