Skip to content

Commit

Permalink
fixed some linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
phin1x committed Jun 25, 2023
1 parent 83741db commit daa1225
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
30 changes: 15 additions & 15 deletions attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -107,15 +107,15 @@ 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:
if tag != TagInteger && tag != TagEnum {
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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand Down Expand Up @@ -243,15 +243,15 @@ 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:
if tag != TagBoolean {
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
}
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion ipp-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit daa1225

Please sign in to comment.