Skip to content

Commit 08ac5ff

Browse files
committed
Fix linter errors
The linter is correctly flagging this bit: fmt.Fprintf(w, ExpectedMessage) because it's a formatting function that doesn't appear to be formatting anything (since there are not additional arguments after the formatting string). staticcheck has started flagging this import: "github.com/golang/protobuf/proto" because that package has been rewritten and published as google.golang.org/protobuf. The new package is not a drop-in replacement for the old one, even if the staticcheck diagnostic suggests otherwise. Newer versions of the old package are actually implemented in terms of the new one. For this code base in particular, some of the text marshalling functions have disappeared in the new package and they need to be implemented in terms of the new reflection package. Until an adequate solution is found, simply ignore the error. Closes: #281 Signed-off-by: Marcelo E. Magallon <[email protected]>
1 parent a1b6ede commit 08ac5ff

File tree

8 files changed

+12
-11
lines changed

8 files changed

+12
-11
lines changed

config/http_config_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,11 +335,11 @@ func TestNewClientFromConfig(t *testing.T) {
335335
handler: func(w http.ResponseWriter, r *http.Request) {
336336
switch r.URL.Path {
337337
case "/redirected":
338-
fmt.Fprintf(w, ExpectedMessage)
338+
fmt.Fprint(w, ExpectedMessage)
339339
default:
340340
w.Header().Set("Location", "/redirected")
341341
w.WriteHeader(http.StatusFound)
342-
fmt.Fprintf(w, "It should follow the redirect.")
342+
fmt.Fprint(w, "It should follow the redirect.")
343343
}
344344
},
345345
}, {
@@ -359,7 +359,7 @@ func TestNewClientFromConfig(t *testing.T) {
359359
default:
360360
w.Header().Set("Location", "/redirected")
361361
w.WriteHeader(http.StatusFound)
362-
fmt.Fprintf(w, ExpectedMessage)
362+
fmt.Fprint(w, ExpectedMessage)
363363
}
364364
},
365365
},

expfmt/decode_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"strings"
2222
"testing"
2323

24-
"github.com/golang/protobuf/proto"
24+
"github.com/golang/protobuf/proto" //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility.
2525
dto "github.com/prometheus/client_model/go"
2626

2727
"github.com/prometheus/common/model"

expfmt/encode.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
"io"
1919
"net/http"
2020

21-
"github.com/golang/protobuf/proto"
21+
"github.com/golang/protobuf/proto" //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility.
2222
"github.com/matttproud/golang_protobuf_extensions/pbutil"
2323
"github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg"
2424

expfmt/encode_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ package expfmt
1515

1616
import (
1717
"bytes"
18-
"github.com/golang/protobuf/proto"
19-
dto "github.com/prometheus/client_model/go"
2018
"net/http"
2119
"testing"
20+
21+
"github.com/golang/protobuf/proto" //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility.
22+
dto "github.com/prometheus/client_model/go"
2223
)
2324

2425
func TestNegotiate(t *testing.T) {

expfmt/openmetrics_create_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"testing"
2121
"time"
2222

23-
"github.com/golang/protobuf/proto"
23+
"github.com/golang/protobuf/proto" //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility.
2424
"github.com/golang/protobuf/ptypes"
2525

2626
dto "github.com/prometheus/client_model/go"

expfmt/text_create_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
"strings"
2020
"testing"
2121

22-
"github.com/golang/protobuf/proto"
22+
"github.com/golang/protobuf/proto" //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility.
2323

2424
dto "github.com/prometheus/client_model/go"
2525
)

expfmt/text_parse.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424

2525
dto "github.com/prometheus/client_model/go"
2626

27-
"github.com/golang/protobuf/proto"
27+
"github.com/golang/protobuf/proto" //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility.
2828
"github.com/prometheus/common/model"
2929
)
3030

expfmt/text_parse_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
"strings"
1919
"testing"
2020

21-
"github.com/golang/protobuf/proto"
21+
"github.com/golang/protobuf/proto" //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility.
2222
dto "github.com/prometheus/client_model/go"
2323
)
2424

0 commit comments

Comments
 (0)