diff --git a/docs/src/miller-as-library/main3.go b/docs/src/miller-as-library/main3.go index 23a400453d..617488c330 100644 --- a/docs/src/miller-as-library/main3.go +++ b/docs/src/miller-as-library/main3.go @@ -89,10 +89,10 @@ func convert_csv_to_json(fileNames []string) error { case ierr := <-inputErrorChannel: retval = ierr break - case _ = <-dataProcessingErrorChannel: + case <-dataProcessingErrorChannel: retval = errors.New("exiting due to data error") // details already printed break - case _ = <-doneWritingChannel: + case <-doneWritingChannel: done = true break } diff --git a/pkg/bifs/arithmetic.go b/pkg/bifs/arithmetic.go index 1edf7cee4a..bffcc5309e 100644 --- a/pkg/bifs/arithmetic.go +++ b/pkg/bifs/arithmetic.go @@ -834,7 +834,7 @@ func min_i_ii(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { // a=F | min=a min=a // a=T | min=b min=b func min_b_bb(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { - if input1.AcquireBoolValue() == false { + if !input1.AcquireBoolValue() { return input1 } else { return input2 @@ -946,7 +946,7 @@ func BIF_minlen_variadic(mlrvals []*mlrval.Mlrval) *mlrval.Mlrval { } // Do the bulk arithmetic on native ints not Mlrvals, to avoid unnecessary allocation. retval := lib.UTF8Strlen(mlrvals[0].OriginalString()) - for i, _ := range mlrvals { + for i := range mlrvals { clen := lib.UTF8Strlen(mlrvals[i].OriginalString()) if clen < retval { retval = clen @@ -1004,7 +1004,7 @@ func max_i_ii(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { // a=F | max=a max=b // a=T | max=a max=b func max_b_bb(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { - if input2.AcquireBoolValue() == false { + if !input2.AcquireBoolValue() { return input1 } else { return input2 @@ -1116,7 +1116,7 @@ func BIF_maxlen_variadic(mlrvals []*mlrval.Mlrval) *mlrval.Mlrval { } // Do the bulk arithmetic on native ints not Mlrvals, to avoid unnecessary allocation. retval := lib.UTF8Strlen(mlrvals[0].OriginalString()) - for i, _ := range mlrvals { + for i := range mlrvals { clen := lib.UTF8Strlen(mlrvals[i].OriginalString()) if clen > retval { retval = clen diff --git a/pkg/bifs/cmp.go b/pkg/bifs/cmp.go index b4603d2a87..3be5179900 100644 --- a/pkg/bifs/cmp.go +++ b/pkg/bifs/cmp.go @@ -246,7 +246,7 @@ func eq_b_aa(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { for i := range a { eq := BIF_equals(a[i], b[i]) lib.InternalCodingErrorIf(eq.Type() != mlrval.MT_BOOL) - if eq.AcquireBoolValue() == false { + if !eq.AcquireBoolValue() { return mlrval.FALSE } } diff --git a/pkg/bifs/regex.go b/pkg/bifs/regex.go index 011c21ac29..2095003a6c 100644 --- a/pkg/bifs/regex.go +++ b/pkg/bifs/regex.go @@ -147,7 +147,7 @@ func BIF_strmatchx(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { captures_array := make([]*mlrval.Mlrval, len(captures)) if len(captures) > 0 { - for i, _ := range captures { + for i := range captures { if i == 0 { results.PutReference("full_capture", mlrval.FromString(captures[i])) } else { @@ -156,7 +156,7 @@ func BIF_strmatchx(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { } starts_array := make([]*mlrval.Mlrval, len(starts)) - for i, _ := range starts { + for i := range starts { if i == 0 { results.PutReference("full_start", mlrval.FromInt(int64(starts[i]))) } else { @@ -165,7 +165,7 @@ func BIF_strmatchx(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { } ends_array := make([]*mlrval.Mlrval, len(ends)) - for i, _ := range ends { + for i := range ends { if i == 0 { results.PutReference("full_end", mlrval.FromInt(int64(ends[i]))) } else { diff --git a/pkg/bifs/stats.go b/pkg/bifs/stats.go index d7bd3f1068..bc9bc6e43c 100644 --- a/pkg/bifs/stats.go +++ b/pkg/bifs/stats.go @@ -636,7 +636,7 @@ func bif_percentiles_impl( outputs := make([]*mlrval.Mlrval, len(ps)) - for i, _ := range ps { + for i := range ps { p, ok := ps[i].GetNumericToFloatValue() if !ok { outputs[i] = type_error_named_argument(funcname, "numeric", "percentile", ps[i]) @@ -655,7 +655,7 @@ func bif_percentiles_impl( return mlrval.FromArray(outputs) } else { m := mlrval.NewMlrmap() - for i, _ := range ps { + for i := range ps { sp := ps[i].String() m.PutCopy(sp, outputs[i]) } diff --git a/pkg/bifs/types.go b/pkg/bifs/types.go index a4eb1f2300..d3e8d61ef9 100644 --- a/pkg/bifs/types.go +++ b/pkg/bifs/types.go @@ -37,7 +37,7 @@ func float_to_int(input1 *mlrval.Mlrval) *mlrval.Mlrval { } func bool_to_int(input1 *mlrval.Mlrval) *mlrval.Mlrval { - if input1.AcquireBoolValue() == true { + if input1.AcquireBoolValue() { return mlrval.FromInt(1) } else { return mlrval.FromInt(0) @@ -92,7 +92,7 @@ func float_to_int_with_base(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { } func bool_to_int_with_base(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { - if input1.AcquireBoolValue() == true { + if input1.AcquireBoolValue() { return mlrval.FromInt(1) } else { return mlrval.FromInt(0) @@ -146,7 +146,7 @@ func int_to_float(input1 *mlrval.Mlrval) *mlrval.Mlrval { } func bool_to_float(input1 *mlrval.Mlrval) *mlrval.Mlrval { - if input1.AcquireBoolValue() == true { + if input1.AcquireBoolValue() { return mlrval.FromFloat(1.0) } else { return mlrval.FromFloat(0.0) diff --git a/pkg/climain/mlrcli_parse.go b/pkg/climain/mlrcli_parse.go index 3641958247..f582cd51ca 100644 --- a/pkg/climain/mlrcli_parse.go +++ b/pkg/climain/mlrcli_parse.go @@ -295,7 +295,7 @@ func parseCommandLinePassTwo( rc := cli.FLAG_TABLE.Parse(args, argc, &argi, options) // Should have been parsed OK in pass one. - lib.InternalCodingErrorIf(rc != true) + lib.InternalCodingErrorIf(!rc) // Make sure we consumed the entire flag sequence as parsed by pass one. lib.InternalCodingErrorIf(argi != argc) } diff --git a/pkg/dsl/cst/builtin_function_manager.go b/pkg/dsl/cst/builtin_function_manager.go index e35ee8b0b4..4a1d83bfab 100644 --- a/pkg/dsl/cst/builtin_function_manager.go +++ b/pkg/dsl/cst/builtin_function_manager.go @@ -2595,7 +2595,7 @@ func (manager *BuiltinFunctionManager) getBuiltinFunctionClasses() []string { classesList := make([]string, 0) for _, builtinFunctionInfo := range *manager.lookupTable { class := string(builtinFunctionInfo.class) - if classesSeen[class] == false { + if !classesSeen[class] { classesList = append(classesList, class) classesSeen[class] = true } diff --git a/pkg/dsl/cst/builtin_functions.go b/pkg/dsl/cst/builtin_functions.go index 3b9fa12f3c..e3558d1cdf 100644 --- a/pkg/dsl/cst/builtin_functions.go +++ b/pkg/dsl/cst/builtin_functions.go @@ -945,7 +945,7 @@ func (node *StandardTernaryOperatorNode) Evaluate( } // Short-circuit: defer evaluation unless needed - if boolValue == true { + if boolValue { return node.b.Evaluate(state) } else { return node.c.Evaluate(state) diff --git a/pkg/dsl/cst/cond.go b/pkg/dsl/cst/cond.go index 53532d9250..52dd30dead 100644 --- a/pkg/dsl/cst/cond.go +++ b/pkg/dsl/cst/cond.go @@ -66,7 +66,7 @@ func (node *CondBlockNode) Execute( ) } - if boolValue == true { + if boolValue { blockExitPayload, err := node.statementBlockNode.Execute(state) if err != nil { return nil, err diff --git a/pkg/dsl/cst/for.go b/pkg/dsl/cst/for.go index 204505aba4..074f3b500d 100644 --- a/pkg/dsl/cst/for.go +++ b/pkg/dsl/cst/for.go @@ -902,7 +902,7 @@ func (node *TripleForLoopNode) Execute(state *runtime.State) (*BlockExitPayload, dsl.TokenToLocationInfo(node.continuationExpressionToken), ) } - if boolValue == false { + if !boolValue { break } } diff --git a/pkg/dsl/cst/if.go b/pkg/dsl/cst/if.go index 3396ddd193..b85f681190 100644 --- a/pkg/dsl/cst/if.go +++ b/pkg/dsl/cst/if.go @@ -134,7 +134,7 @@ func (node *IfChainNode) Execute(state *runtime.State) (*BlockExitPayload, error dsl.TokenToLocationInfo(ifItem.conditionToken), ) } - if boolValue == true { + if boolValue { blockExitPayload, err := ifItem.statementBlockNode.Execute(state) if err != nil { return nil, err diff --git a/pkg/dsl/cst/udf.go b/pkg/dsl/cst/udf.go index e1544d7b2e..f3550669e4 100644 --- a/pkg/dsl/cst/udf.go +++ b/pkg/dsl/cst/udf.go @@ -495,6 +495,9 @@ func (root *RootNode) BuildUDF( "function return value", returnValueTypeName, ) + if err != nil { + return nil, err + } lib.InternalCodingErrorIf(parameterListASTNode.Type != dsl.NodeTypeParameterList) lib.InternalCodingErrorIf(parameterListASTNode.Children == nil) diff --git a/pkg/dsl/cst/while.go b/pkg/dsl/cst/while.go index 2e2fd5f125..ccdde00524 100644 --- a/pkg/dsl/cst/while.go +++ b/pkg/dsl/cst/while.go @@ -64,7 +64,7 @@ func (node *WhileLoopNode) Execute(state *runtime.State) (*BlockExitPayload, err dsl.TokenToLocationInfo(node.conditionToken), ) } - if boolValue != true { + if !boolValue { break } blockExitPayload, err := node.statementBlockNode.Execute(state) @@ -161,7 +161,7 @@ func (node *DoWhileLoopNode) Execute(state *runtime.State) (*BlockExitPayload, e dsl.TokenToLocationInfo(node.conditionToken), ) } - if boolValue == false { + if !boolValue { break } } diff --git a/pkg/input/line_reader.go b/pkg/input/line_reader.go index 663178c5df..b1f965307b 100644 --- a/pkg/input/line_reader.go +++ b/pkg/input/line_reader.go @@ -201,7 +201,7 @@ func channelizedLineReader( // quickly, as it should. if i%recordsPerBatch == 0 { select { - case _ = <-downstreamDoneChannel: + case <-downstreamDoneChannel: done = true break default: diff --git a/pkg/input/pseudo_reader_gen.go b/pkg/input/pseudo_reader_gen.go index fa949e01ae..e847b59ab5 100644 --- a/pkg/input/pseudo_reader_gen.go +++ b/pkg/input/pseudo_reader_gen.go @@ -96,7 +96,7 @@ func (reader *PseudoReaderGen) process( // avoid goroutine-scheduler thrash. eof := false select { - case _ = <-downstreamDoneChannel: + case <-downstreamDoneChannel: eof = true break default: @@ -113,7 +113,6 @@ func (reader *PseudoReaderGen) process( if recordsAndContexts.Len() > 0 { readerChannel <- recordsAndContexts - recordsAndContexts = list.New() } } diff --git a/pkg/input/record_reader_csv.go b/pkg/input/record_reader_csv.go index 20c1fd15d1..6ed07250d8 100644 --- a/pkg/input/record_reader_csv.go +++ b/pkg/input/record_reader_csv.go @@ -158,7 +158,7 @@ func channelizedCSVRecordScanner( // quickly, as it should. if i%recordsPerBatch == 0 { select { - case _ = <-downstreamDoneChannel: + case <-downstreamDoneChannel: done = true break default: diff --git a/pkg/input/record_reader_json.go b/pkg/input/record_reader_json.go index 096e506fb5..52844025e7 100644 --- a/pkg/input/record_reader_json.go +++ b/pkg/input/record_reader_json.go @@ -99,7 +99,7 @@ func (reader *RecordReaderJSON) processHandle( i++ if i%recordsPerBatch == 0 { select { - case _ = <-downstreamDoneChannel: + case <-downstreamDoneChannel: eof = true break default: diff --git a/pkg/input/record_reader_pprint.go b/pkg/input/record_reader_pprint.go index b83710f7bc..aad87769c2 100644 --- a/pkg/input/record_reader_pprint.go +++ b/pkg/input/record_reader_pprint.go @@ -227,7 +227,7 @@ func getRecordBatchExplicitPprintHeader( continue } fields := make([]string, npad-2) - for i, _ := range paddedFields { + for i := range paddedFields { if i == 0 || i == npad-1 { continue } @@ -361,7 +361,7 @@ func getRecordBatchImplicitPprintHeader( paddedFields := reader.fieldSplitter.Split(line) npad := len(paddedFields) fields := make([]string, npad-2) - for i, _ := range paddedFields { + for i := range paddedFields { if i == 0 || i == npad-1 { continue } diff --git a/pkg/input/record_reader_xtab.go b/pkg/input/record_reader_xtab.go index b108f771db..5d15300074 100644 --- a/pkg/input/record_reader_xtab.go +++ b/pkg/input/record_reader_xtab.go @@ -202,7 +202,7 @@ func channelizedStanzaScanner( // quickly, as it should. if numStanzasSeen%recordsPerBatch == 0 { select { - case _ = <-downstreamDoneChannel: + case <-downstreamDoneChannel: done = true break default: diff --git a/pkg/lib/halfpipe.go b/pkg/lib/halfpipe.go index 040896a002..3b926ef3fb 100644 --- a/pkg/lib/halfpipe.go +++ b/pkg/lib/halfpipe.go @@ -21,6 +21,9 @@ import ( func OpenOutboundHalfPipe(commandString string) (*os.File, error) { readPipe, writePipe, err := os.Pipe() + if err != nil { + return nil, err + } var procAttr os.ProcAttr procAttr.Files = []*os.File{ @@ -56,6 +59,9 @@ func OpenOutboundHalfPipe(commandString string) (*os.File, error) { func OpenInboundHalfPipe(commandString string) (*os.File, error) { readPipe, writePipe, err := os.Pipe() + if err != nil { + return nil, err + } var procAttr os.ProcAttr procAttr.Files = []*os.File{ diff --git a/pkg/lib/util.go b/pkg/lib/util.go index 37e90ce469..f37194ccb4 100644 --- a/pkg/lib/util.go +++ b/pkg/lib/util.go @@ -14,7 +14,7 @@ func BooleanXOR(a, b bool) bool { } func BoolToInt(b bool) int64 { - if b == false { + if !b { return 0 } else { return 1 diff --git a/pkg/mlrval/mlrval_get_test.go b/pkg/mlrval/mlrval_get_test.go index 9107fbdc90..90abc85981 100644 --- a/pkg/mlrval/mlrval_get_test.go +++ b/pkg/mlrval/mlrval_get_test.go @@ -12,23 +12,23 @@ import ( func TestGetString(t *testing.T) { mv := FromInferredType("234") - stringval, ok := mv.GetStringValue() + _, ok := mv.GetStringValue() assert.False(t, ok) mv = FromDeferredType("234") - stringval, ok = mv.GetStringValue() + _, ok = mv.GetStringValue() assert.False(t, ok) mv = FromInferredType("234.5") - stringval, ok = mv.GetStringValue() + _, ok = mv.GetStringValue() assert.False(t, ok) mv = FromDeferredType("234.5") - stringval, ok = mv.GetStringValue() + _, ok = mv.GetStringValue() assert.False(t, ok) mv = FromInferredType("abc") - stringval, ok = mv.GetStringValue() + stringval, ok := mv.GetStringValue() assert.Equal(t, "abc", stringval) assert.True(t, ok) @@ -60,33 +60,33 @@ func TestGetIntValue(t *testing.T) { assert.True(t, ok) mv = FromInferredType("123.4") - intval, ok = mv.GetIntValue() + _, ok = mv.GetIntValue() assert.False(t, ok) mv = FromDeferredType("123.4") - intval, ok = mv.GetIntValue() + _, ok = mv.GetIntValue() assert.False(t, ok) mv = FromInferredType("abc") - intval, ok = mv.GetIntValue() + _, ok = mv.GetIntValue() assert.False(t, ok) mv = FromDeferredType("abc") - intval, ok = mv.GetIntValue() + _, ok = mv.GetIntValue() assert.False(t, ok) } func TestGetFloatValue(t *testing.T) { mv := FromInferredType("234") - floatval, ok := mv.GetFloatValue() + _, ok := mv.GetFloatValue() assert.False(t, ok) mv = FromDeferredType("234") - floatval, ok = mv.GetFloatValue() + _, ok = mv.GetFloatValue() assert.False(t, ok) mv = FromInferredType("234.5") - floatval, ok = mv.GetFloatValue() + floatval, ok := mv.GetFloatValue() assert.Equal(t, 234.5, floatval) assert.True(t, ok) @@ -96,11 +96,11 @@ func TestGetFloatValue(t *testing.T) { assert.True(t, ok) mv = FromInferredType("abc") - floatval, ok = mv.GetFloatValue() + _, ok = mv.GetFloatValue() assert.False(t, ok) mv = FromDeferredType("abc") - floatval, ok = mv.GetFloatValue() + _, ok = mv.GetFloatValue() assert.False(t, ok) } @@ -126,38 +126,38 @@ func TestGetNumericToFloatValue(t *testing.T) { assert.True(t, ok) mv = FromInferredType("abc") - floatval, ok = mv.GetNumericToFloatValue() + _, ok = mv.GetNumericToFloatValue() assert.False(t, ok) mv = FromDeferredType("abc") - floatval, ok = mv.GetNumericToFloatValue() + _, ok = mv.GetNumericToFloatValue() assert.False(t, ok) } func TestGetBoolValue(t *testing.T) { mv := FromInferredType("234") - boolval, ok := mv.GetBoolValue() + _, ok := mv.GetBoolValue() assert.False(t, ok) mv = FromDeferredType("234") - boolval, ok = mv.GetBoolValue() + _, ok = mv.GetBoolValue() assert.False(t, ok) mv = FromInferredType("abc") - boolval, ok = mv.GetBoolValue() + _, ok = mv.GetBoolValue() assert.False(t, ok) mv = FromDeferredType("abc") - boolval, ok = mv.GetBoolValue() + _, ok = mv.GetBoolValue() assert.False(t, ok) mv = FromInferredType("true") - boolval, ok = mv.GetBoolValue() + boolval, ok := mv.GetBoolValue() assert.True(t, boolval) assert.True(t, ok) mv = FromDeferredType("false") - boolval, ok = mv.GetBoolValue() + _, ok = mv.GetBoolValue() assert.False(t, ok, "from-data-file \"false\" should infer to string") } diff --git a/pkg/mlrval/mlrval_is.go b/pkg/mlrval/mlrval_is.go index 7f438871f5..0cdfdadded 100644 --- a/pkg/mlrval/mlrval_is.go +++ b/pkg/mlrval/mlrval_is.go @@ -112,10 +112,10 @@ func (mv *Mlrval) IsBool() bool { } func (mv *Mlrval) IsTrue() bool { - return mv.Type() == MT_BOOL && mv.intf.(bool) == true + return mv.Type() == MT_BOOL && mv.intf.(bool) } func (mv *Mlrval) IsFalse() bool { - return mv.Type() == MT_BOOL && mv.intf.(bool) == false + return mv.Type() == MT_BOOL && !mv.intf.(bool) } func (mv *Mlrval) IsArray() bool { diff --git a/pkg/mlrval/mlrval_json.go b/pkg/mlrval/mlrval_json.go index a5dc213a7b..d1fb880ede 100644 --- a/pkg/mlrval/mlrval_json.go +++ b/pkg/mlrval/mlrval_json.go @@ -188,7 +188,9 @@ func MlrvalDecodeFromJSON(decoder *json.Decoder) ( ) } - mv := FromPending() + // Will be assigned as an array or a map + var mv *Mlrval + if isArray { mv = FromEmptyArray() @@ -203,7 +205,6 @@ func MlrvalDecodeFromJSON(decoder *json.Decoder) ( } mv.ArrayAppend(element) } - } else { mv = FromEmptyMap() diff --git a/pkg/mlrval/mlrval_new.go b/pkg/mlrval/mlrval_new.go index bcad5590b8..9d63989b12 100644 --- a/pkg/mlrval/mlrval_new.go +++ b/pkg/mlrval/mlrval_new.go @@ -289,7 +289,7 @@ func FromPrevalidatedFloatString(input string, floatval float64) *Mlrval { } func FromBool(input bool) *Mlrval { - if input == true { + if input { return TRUE } else { return FALSE diff --git a/pkg/mlrval/mlrval_output.go b/pkg/mlrval/mlrval_output.go index d864806b3c..b6fd84e0fe 100644 --- a/pkg/mlrval/mlrval_output.go +++ b/pkg/mlrval/mlrval_output.go @@ -87,7 +87,7 @@ func (mv *Mlrval) setPrintRep() { mv.printrep = strconv.FormatFloat(mv.intf.(float64), 'f', -1, 64) case MT_BOOL: - if mv.intf.(bool) == true { + if mv.intf.(bool) { mv.printrep = "true" } else { mv.printrep = "false" @@ -120,7 +120,7 @@ func (mv *Mlrval) StringifyValuesRecursively() { switch mv.mvtype { case MT_ARRAY: - for i, _ := range mv.intf.([]*Mlrval) { + for i := range mv.intf.([]*Mlrval) { mv.intf.([]*Mlrval)[i].StringifyValuesRecursively() } diff --git a/pkg/output/file_output_handlers.go b/pkg/output/file_output_handlers.go index d47617cc05..31f6b89a0a 100644 --- a/pkg/output/file_output_handlers.go +++ b/pkg/output/file_output_handlers.go @@ -399,13 +399,11 @@ func (handler *FileOutputHandler) Close() (retval error) { done := false for !done { select { - case _ = <-handler.recordErroredChannel: + case <-handler.recordErroredChannel: done = true retval = errors.New("exiting due to data error") // details already printed - break - case _ = <-handler.recordDoneChannel: + case <-handler.recordDoneChannel: done = true - break } } } diff --git a/pkg/platform/getargs_windows.go b/pkg/platform/getargs_windows.go index 4349e43462..7a2f1af3d5 100644 --- a/pkg/platform/getargs_windows.go +++ b/pkg/platform/getargs_windows.go @@ -79,7 +79,7 @@ func GetArgs() []string { //printArgs(retargs, "NEW") globbed := make([]string, 0) - for i, _ := range retargs { + for i := range retargs { // Expand things like *.csv matches, err := filepath.Glob(retargs[i]) if matches != nil && err == nil { diff --git a/pkg/stream/stream.go b/pkg/stream/stream.go index 84f096fafa..1aafe95c98 100644 --- a/pkg/stream/stream.go +++ b/pkg/stream/stream.go @@ -95,13 +95,10 @@ func Stream( select { case ierr := <-inputErrorChannel: retval = ierr - break - case _ = <-dataProcessingErrorChannel: + case <-dataProcessingErrorChannel: retval = errors.New("exiting due to data error") // details already printed - break - case _ = <-doneWritingChannel: + case <-doneWritingChannel: done = true - break } } diff --git a/pkg/terminals/repl/session.go b/pkg/terminals/repl/session.go index 27bd3896a6..2f25beb319 100644 --- a/pkg/terminals/repl/session.go +++ b/pkg/terminals/repl/session.go @@ -176,7 +176,7 @@ func (repl *Repl) handleSession(istream *os.File) error { doneDraining := false for { select { - case _ = <-repl.appSignalNotificationChannel: + case <-repl.appSignalNotificationChannel: line = "" // Ignore any partially-entered line -- a ^C should do that default: doneDraining = true diff --git a/pkg/terminals/repl/verbs.go b/pkg/terminals/repl/verbs.go index bbb1a36b23..c2b992746b 100644 --- a/pkg/terminals/repl/verbs.go +++ b/pkg/terminals/repl/verbs.go @@ -442,11 +442,8 @@ func handleSkipOrProcessN(repl *Repl, n int64, processingNotSkipping bool) { for i := int64(1); i <= n; i++ { select { case recordsAndContexts = <-repl.readerChannel: - break case err = <-repl.errorChannel: - break - case _ = <-repl.appSignalNotificationChannel: // user typed control-C - break + case <-repl.appSignalNotificationChannel: // user typed control-C } if err != nil { @@ -505,13 +502,11 @@ func handleSkipOrProcessUntil(repl *Repl, dslString string, processingNotSkippin doubleBreak := false select { case recordsAndContexts = <-repl.readerChannel: - break case err = <-repl.errorChannel: - break - case _ = <-repl.appSignalNotificationChannel: // user typed control-C + case <-repl.appSignalNotificationChannel: // user typed control-C doubleBreak = true - break } + if doubleBreak { break } @@ -566,7 +561,7 @@ func skipOrProcessRecord( repl.runtimeState.Update(recordAndContext.Record, &recordAndContext.Context) // End-of-stream marker - if recordAndContext.EndOfStream == true { + if recordAndContext.EndOfStream { fmt.Println("End of record stream") repl.readerChannel = nil repl.errorChannel = nil diff --git a/pkg/transformers/aaa_chain_transformer.go b/pkg/transformers/aaa_chain_transformer.go index 6b67b03b75..a4137b7633 100644 --- a/pkg/transformers/aaa_chain_transformer.go +++ b/pkg/transformers/aaa_chain_transformer.go @@ -265,7 +265,7 @@ func runSingleTransformerBatch( // the output channel without involving the record-transformer, since // there is no record to be transformed. - if inputRecordAndContext.EndOfStream == true || inputRecordAndContext.Record != nil { + if inputRecordAndContext.EndOfStream || inputRecordAndContext.Record != nil { recordTransformer.Transform( inputRecordAndContext, outputRecordsAndContexts, diff --git a/pkg/transformers/put_or_filter.go b/pkg/transformers/put_or_filter.go index 9749033452..648595ce24 100644 --- a/pkg/transformers/put_or_filter.go +++ b/pkg/transformers/put_or_filter.go @@ -542,7 +542,7 @@ func (tr *TransformerPut) Transform( // If there were no input records then we never executed the // begin-blocks. Do so now. - if tr.executedBeginBlocks == false { + if !tr.executedBeginBlocks { err := tr.cstRootNode.ExecuteBeginBlocks(tr.runtimeState) if err != nil { fmt.Fprintln(os.Stderr, err) diff --git a/pkg/transformers/seqgen.go b/pkg/transformers/seqgen.go index 560df4ed30..9d77e71738 100644 --- a/pkg/transformers/seqgen.go +++ b/pkg/transformers/seqgen.go @@ -192,9 +192,7 @@ func (tr *TransformerSeqgen) Transform( case b := <-inputDownstreamDoneChannel: outputDownstreamDoneChannel <- b keepGoing = false - break default: - break } if !keepGoing { break diff --git a/pkg/transformers/tee.go b/pkg/transformers/tee.go index bff0065ea7..e5f5413cad 100644 --- a/pkg/transformers/tee.go +++ b/pkg/transformers/tee.go @@ -183,7 +183,7 @@ func (tr *TransformerTee) Transform( // But 'mlr cut -f foo then tee bar.txt then head -n 10' -- one does expect // bar.txt to have all the output from cut. select { - case _ = <-inputDownstreamDoneChannel: + case <-inputDownstreamDoneChannel: // Do not write this to the coutputDownstreamDoneChannel, as other transformers do break default: