Browse Source

golint corrections

pull/1842/head
rigel rozanski 7 years ago
parent
commit
925f2b3350
1 changed files with 5 additions and 1 deletions
  1. +5
    -1
      common/string.go

+ 5
- 1
common/string.go View File

@ -6,8 +6,10 @@ import (
"strings" "strings"
) )
// Fmt shorthand, XXX DEPRECATED
var Fmt = fmt.Sprintf var Fmt = fmt.Sprintf
// RightPadString adds spaces to the right of a string to make it length totalLength
func RightPadString(s string, totalLength int) string { func RightPadString(s string, totalLength int) string {
remaining := totalLength - len(s) remaining := totalLength - len(s)
if remaining > 0 { if remaining > 0 {
@ -16,6 +18,7 @@ func RightPadString(s string, totalLength int) string {
return s return s
} }
// LeftPadString adds spaces to the left of a string to make it length totalLength
func LeftPadString(s string, totalLength int) string { func LeftPadString(s string, totalLength int) string {
remaining := totalLength - len(s) remaining := totalLength - len(s)
if remaining > 0 { if remaining > 0 {
@ -24,7 +27,7 @@ func LeftPadString(s string, totalLength int) string {
return s return s
} }
// Returns true for non-empty hex-string prefixed with "0x"
// IsHex returns true for non-empty hex-string prefixed with "0x"
func IsHex(s string) bool { func IsHex(s string) bool {
if len(s) > 2 && s[:2] == "0x" { if len(s) > 2 && s[:2] == "0x" {
_, err := hex.DecodeString(s[2:]) _, err := hex.DecodeString(s[2:])
@ -36,6 +39,7 @@ func IsHex(s string) bool {
return false return false
} }
// StripHex returns hex string without leading "0x"
func StripHex(s string) string { func StripHex(s string) string {
if IsHex(s) { if IsHex(s) {
return s[2:] return s[2:]


Loading…
Cancel
Save