diff --git a/tools/goctl/util/string.go b/tools/goctl/util/string.go index 707f2c75c..05c76916e 100644 --- a/tools/goctl/util/string.go +++ b/tools/goctl/util/string.go @@ -2,7 +2,6 @@ package util import ( "slices" - "strconv" "strings" "github.com/zeromicro/go-zero/tools/goctl/util/console" @@ -130,14 +129,3 @@ func FieldsAndTrimSpace(s string, f func(r rune) bool) []string { } return resp } - -//Deprecated: This function implementation is incomplete and does not properly handle exceptional input cases. -//We strongly recommend using the standard library's strconv.Unquote function instead, -//which provides robust error handling and comprehensive support for various input formats. -func Unquote(s string) string { - ns, err := strconv.Unquote(s) - if err != nil { - return "" - } - return ns -} diff --git a/tools/goctl/util/string_test.go b/tools/goctl/util/string_test.go index 548fee67e..18bb8fa49 100644 --- a/tools/goctl/util/string_test.go +++ b/tools/goctl/util/string_test.go @@ -76,40 +76,40 @@ func TestEscapeGoKeyword(t *testing.T) { func TestFieldsAndTrimSpace(t *testing.T) { testCases := []struct { - name string - input string + name string + input string delimiter func(r rune) bool - expected []string + expected []string }{ { - name: "Comma-separated values", - input: "a, b, c", + name: "Comma-separated values", + input: "a, b, c", delimiter: func(r rune) bool { return r == ',' }, - expected: []string{"a", " b", " c"}, + expected: []string{"a", " b", " c"}, }, { - name: "Space-separated values", - input: "a b c", + name: "Space-separated values", + input: "a b c", delimiter: unicode.IsSpace, - expected: []string{"a", "b", "c"}, + expected: []string{"a", "b", "c"}, }, { - name: "Mixed whitespace", - input: "a\tb\nc", + name: "Mixed whitespace", + input: "a\tb\nc", delimiter: unicode.IsSpace, - expected: []string{"a", "b", "c"}, + expected: []string{"a", "b", "c"}, }, { - name: "Empty input", - input: "", + name: "Empty input", + input: "", delimiter: unicode.IsSpace, - expected: []string(nil), + expected: []string(nil), }, { - name: "Trailing and leading spaces", - input: " a , b , c ", + name: "Trailing and leading spaces", + input: " a , b , c ", delimiter: func(r rune) bool { return r == ',' }, - expected: []string{" a ", " b ", " c "}, + expected: []string{" a ", " b ", " c "}, }, } @@ -120,20 +120,3 @@ func TestFieldsAndTrimSpace(t *testing.T) { }) } } - -func TestUnquote(t *testing.T) { - testCases := []struct { - input string - expected string - }{ - {input: `"hello"`, expected: `hello`}, - {input: "`world`", expected: `world`}, - {input: `"foo'bar"`, expected: `foo'bar`}, - {input: "", expected: ""}, - } - - for _, tc := range testCases { - result := Unquote(tc.input) - assert.Equal(t, tc.expected, result) - } -}