From 2014e923a0a5728c4cea5210948322ef6c634390 Mon Sep 17 00:00:00 2001 From: Wilken Rivera Date: Fri, 21 Jun 2024 15:10:30 -0400 Subject: [PATCH] Drop redundant guard cases The upper index bound for a slice is cap(args) we can safely retun appended slices ``` ~> go test -count=1 ./plugin/... -v === RUN TestPluginServerRandom --- PASS: TestPluginServerRandom (0.00s) === RUN TestSet --- PASS: TestSet (0.00s) === RUN TestSetProtobufArgParsing === RUN TestSetProtobufArgParsing/no_--protobuf_argument_provided === RUN TestSetProtobufArgParsing/providing_--protobuf_as_first_argument === RUN TestSetProtobufArgParsing/providing_--protobuf_as_last_argument === RUN TestSetProtobufArgParsing/providing_--protobuf_as_middle_argument --- PASS: TestSetProtobufArgParsing (0.00s) --- PASS: TestSetProtobufArgParsing/no_--protobuf_argument_provided (0.00s) --- PASS: TestSetProtobufArgParsing/providing_--protobuf_as_first_argument (0.00s) --- PASS: TestSetProtobufArgParsing/providing_--protobuf_as_last_argument (0.00s) --- PASS: TestSetProtobufArgParsing/providing_--protobuf_as_middle_argument (0.00s) PASS ok github.com/hashicorp/packer-plugin-sdk/plugin 0.244s ``` --- plugin/set.go | 9 --------- 1 file changed, 9 deletions(-) diff --git a/plugin/set.go b/plugin/set.go index 198e88a44..f94319bbf 100644 --- a/plugin/set.go +++ b/plugin/set.go @@ -133,15 +133,6 @@ func (i *Set) parseProtobufFlag(args ...string) []string { } i.useProto = true - - if protobufPos == 0 { - return args[1:] - } - - if protobufPos == len(args)-1 { - return args[:len(args)-1] - } - return append(args[:protobufPos], args[protobufPos+1:]...) }