Skip to content

Commit

Permalink
fix: gosec cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdecaf committed Oct 9, 2024
1 parent d64e0bf commit 3296152
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
16 changes: 7 additions & 9 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,26 @@

package fincen

import "fmt"
import (
"fmt"
)

// NewErrTextLength returns an error that the length of value is invalid
func NewErrValueInvalid(typeStr string) error {
errStr := fmt.Sprintf("The %s has invalid value", typeStr)
return fmt.Errorf(errStr)
return fmt.Errorf("The %s has invalid value", typeStr)
}

// NewErrFieldRequired returns an error when a field is required
func NewErrFieldRequired(typeStr string) error {
errStr := fmt.Sprintf("The %s is a required field", typeStr)
return fmt.Errorf(errStr)
return fmt.Errorf("The %s is a required field", typeStr)
}

// NewErrFiledOmitted returns an error that the field should be omitted
func NewErrFiledOmitted(typeStr string) error {
errStr := fmt.Sprintf("The %s should be omitted", typeStr)
return fmt.Errorf(errStr)
return fmt.Errorf("The %s should be omitted", typeStr)
}

// NewErrMinMaxRange returns an error that the field has min/max element range
func NewErrMinMaxRange(typeStr string) error {
errStr := fmt.Sprintf("The %s has invalid min & max range", typeStr)
return fmt.Errorf(errStr)
return fmt.Errorf("The %s has invalid min & max range", typeStr)
}
7 changes: 6 additions & 1 deletion utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ func NumericStringField(s string, max uint) string {
if ln > max {
return s[ln-max:]
}
s = strings.Repeat("0", int(max-ln)) + s
rem := max - ln
if rem > 1_000_000_000 {
return ""
} else {
s = strings.Repeat("0", int(rem)) + s
}
return s
}

Expand Down

0 comments on commit 3296152

Please sign in to comment.