refactor: implement most of ps plugin in golang
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"reflect"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"unicode"
|
||||
|
||||
@@ -379,6 +380,16 @@ func ToBool(s string) bool {
|
||||
return s == "true"
|
||||
}
|
||||
|
||||
// ToInt returns an int value for a given string
|
||||
func ToInt(s string, defaultValue int) int {
|
||||
i, err := strconv.Atoi(s)
|
||||
if err != nil {
|
||||
return defaultValue
|
||||
}
|
||||
|
||||
return i
|
||||
}
|
||||
|
||||
// UcFirst uppercases the first character in a string
|
||||
func UcFirst(str string) string {
|
||||
for i, v := range str {
|
||||
|
||||
Reference in New Issue
Block a user