Enable linter revive and resolve found errors: part 1

Signed-off-by: Xun Jiang <blackpiglet@gmail.com>
This commit is contained in:
Xun Jiang
2023-04-25 23:15:15 +08:00
parent a0b0b7cd9b
commit 180cc4e31d
40 changed files with 150 additions and 171 deletions
+5 -5
View File
@@ -35,15 +35,15 @@ import (
func Encode(obj runtime.Object, format string) ([]byte, error) {
buf := new(bytes.Buffer)
if err := EncodeTo(obj, format, buf); err != nil {
if err := To(obj, format, buf); err != nil {
return nil, err
}
return buf.Bytes(), nil
}
// EncodeTo converts the provided object to the specified format and
// To converts the provided object to the specified format and
// writes the encoded data to the provided io.Writer.
func EncodeTo(obj runtime.Object, format string, w io.Writer) error {
func To(obj runtime.Object, format string, w io.Writer) error {
encoder, err := EncoderFor(format, obj)
if err != nil {
return err
@@ -73,8 +73,8 @@ func EncoderFor(format string, obj runtime.Object) (runtime.Encoder, error) {
return encoder, nil
}
// EncodeToJSONGzip takes arbitrary Go data and encodes it to GZip compressed JSON in a buffer, as well as a description of the data to put into an error should encoding fail.
func EncodeToJSONGzip(data interface{}, desc string) (*bytes.Buffer, []error) {
// ToJSONGzip takes arbitrary Go data and encodes it to GZip compressed JSON in a buffer, as well as a description of the data to put into an error should encoding fail.
func ToJSONGzip(data interface{}, desc string) (*bytes.Buffer, []error) {
buf := new(bytes.Buffer)
gzw := gzip.NewWriter(buf)