From daa12251bf771eb236882e5d2d66dc9393668be8 Mon Sep 17 00:00:00 2001 From: phin1x Date: Sun, 25 Jun 2023 12:45:18 +0200 Subject: [PATCH] fixed some linting errors --- attribute.go | 30 +++++++++++++++--------------- ipp-client.go | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/attribute.go b/attribute.go index 69610f9..a9b4ba7 100644 --- a/attribute.go +++ b/attribute.go @@ -29,7 +29,7 @@ func (e *AttributeEncoder) Encode(attribute string, value interface{}) error { return fmt.Errorf("cannot get tag of attribute %s", attribute) } - switch value.(type) { + switch v := value.(type) { case int: if tag != TagInteger && tag != TagEnum { return fmt.Errorf("tag for attribute %s does not match with value type", attribute) @@ -43,7 +43,7 @@ func (e *AttributeEncoder) Encode(attribute string, value interface{}) error { return err } - if err := e.encodeInteger(int32(value.(int))); err != nil { + if err := e.encodeInteger(int32(v)); err != nil { return err } case int16: @@ -59,7 +59,7 @@ func (e *AttributeEncoder) Encode(attribute string, value interface{}) error { return err } - if err := e.encodeInteger(int32(value.(int16))); err != nil { + if err := e.encodeInteger(int32(v)); err != nil { return err } case int8: @@ -75,7 +75,7 @@ func (e *AttributeEncoder) Encode(attribute string, value interface{}) error { return err } - if err := e.encodeInteger(int32(value.(int8))); err != nil { + if err := e.encodeInteger(int32(v)); err != nil { return err } case int32: @@ -91,7 +91,7 @@ func (e *AttributeEncoder) Encode(attribute string, value interface{}) error { return err } - if err := e.encodeInteger(value.(int32)); err != nil { + if err := e.encodeInteger(v); err != nil { return err } case int64: @@ -107,7 +107,7 @@ func (e *AttributeEncoder) Encode(attribute string, value interface{}) error { return err } - if err := e.encodeInteger(int32(value.(int64))); err != nil { + if err := e.encodeInteger(int32(v)); err != nil { return err } case []int: @@ -115,7 +115,7 @@ func (e *AttributeEncoder) Encode(attribute string, value interface{}) error { return fmt.Errorf("tag for attribute %s does not match with value type", attribute) } - for index, val := range value.([]int) { + for index, val := range v { if err := e.encodeTag(tag); err != nil { return err } @@ -139,7 +139,7 @@ func (e *AttributeEncoder) Encode(attribute string, value interface{}) error { return fmt.Errorf("tag for attribute %s does not match with value type", attribute) } - for index, val := range value.([]int16) { + for index, val := range v { if err := e.encodeTag(tag); err != nil { return err } @@ -163,7 +163,7 @@ func (e *AttributeEncoder) Encode(attribute string, value interface{}) error { return fmt.Errorf("tag for attribute %s does not match with value type", attribute) } - for index, val := range value.([]int8) { + for index, val := range v { if err := e.encodeTag(tag); err != nil { return err } @@ -187,7 +187,7 @@ func (e *AttributeEncoder) Encode(attribute string, value interface{}) error { return fmt.Errorf("tag for attribute %s does not match with value type", attribute) } - for index, val := range value.([]int32) { + for index, val := range v { if err := e.encodeTag(tag); err != nil { return err } @@ -211,7 +211,7 @@ func (e *AttributeEncoder) Encode(attribute string, value interface{}) error { return fmt.Errorf("tag for attribute %s does not match with value type", attribute) } - for index, val := range value.([]int64) { + for index, val := range v { if err := e.encodeTag(tag); err != nil { return err } @@ -243,7 +243,7 @@ func (e *AttributeEncoder) Encode(attribute string, value interface{}) error { return err } - if err := e.encodeBoolean(value.(bool)); err != nil { + if err := e.encodeBoolean(v); err != nil { return err } case []bool: @@ -251,7 +251,7 @@ func (e *AttributeEncoder) Encode(attribute string, value interface{}) error { return fmt.Errorf("tag for attribute %s does not match with value type", attribute) } - for index, val := range value.([]bool) { + for index, val := range v { if err := e.encodeTag(tag); err != nil { return err } @@ -279,11 +279,11 @@ func (e *AttributeEncoder) Encode(attribute string, value interface{}) error { return err } - if err := e.encodeString(value.(string)); err != nil { + if err := e.encodeString(v); err != nil { return err } case []string: - for index, val := range value.([]string) { + for index, val := range v { if err := e.encodeTag(tag); err != nil { return err } diff --git a/ipp-client.go b/ipp-client.go index 1451746..03af4be 100644 --- a/ipp-client.go +++ b/ipp-client.go @@ -54,7 +54,7 @@ func (c *IPPClient) getClassUri(printer string) string { // SendRequest sends a request to a remote uri end returns the response func (c *IPPClient) SendRequest(url string, req *Request, additionalResponseData io.Writer) (*Response, error) { - if _, ok := req.OperationAttributes[AttributeRequestingUserName]; ok == false { + if _, ok := req.OperationAttributes[AttributeRequestingUserName]; !ok { req.OperationAttributes[AttributeRequestingUserName] = c.username }