diff --git a/builtin/stringslice/stringslice.go b/builtin/stringslice/stringslice.go index 32944d997..49306ad06 100644 --- a/builtin/stringslice/stringslice.go +++ b/builtin/stringslice/stringslice.go @@ -17,14 +17,14 @@ package stringslice import ( - "github.com/goplus/gop/builtin/strx" + "github.com/qiniu/x/stringutil" ) // Capitalize capitalizes the first letter of each string in the slice. func Capitalize(a []string) []string { r := make([]string, len(a)) for i, v := range a { - r[i] = strx.Capitalize(v) + r[i] = stringutil.Capitalize(v) } return r } diff --git a/builtin/strx/stringutil.go b/builtin/strx/stringutil.go deleted file mode 100644 index edcead531..000000000 --- a/builtin/strx/stringutil.go +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2025 The GoPlus Authors (goplus.org). All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package strx - -import ( - "unicode" - "unicode/utf8" - - "github.com/qiniu/x/stringutil" -) - -// Capitalize returns a copy of the string str with the first letter mapped to -// its upper case. -func Capitalize(str string) string { - c, nc := utf8.DecodeRuneInString(str) - if c == utf8.RuneError || unicode.IsUpper(c) { - return str - } - ret := make([]byte, len(str)) - nr := utf8.EncodeRune(ret, unicode.ToUpper(c)) - ret = append(ret[:nr], str[nc:]...) - return stringutil.String(ret) -} diff --git a/cl/builtin.go b/cl/builtin.go index e0784a102..b0abdcc67 100644 --- a/cl/builtin.go +++ b/cl/builtin.go @@ -81,7 +81,7 @@ func newBuiltinDefault(pkg *gogen.Package, conf *gogen.Config) *types.Package { buil := pkg.TryImport("github.com/goplus/gop/builtin") ng := pkg.TryImport("github.com/goplus/gop/builtin/ng") iox := pkg.TryImport("github.com/goplus/gop/builtin/iox") - strx := pkg.TryImport("github.com/goplus/gop/builtin/strx") + strx := pkg.TryImport("github.com/qiniu/x/stringutil") stringslice := pkg.TryImport("github.com/goplus/gop/builtin/stringslice") pkg.TryImport("strconv") pkg.TryImport("strings") diff --git a/go.mod b/go.mod index 524bdfbcb..a060fd1f5 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/goplus/gogen v1.16.6-0.20250112115237-4fcb9989182e github.com/goplus/llgo v0.9.9 github.com/goplus/mod v0.13.15 - github.com/qiniu/x v1.13.10 + github.com/qiniu/x v1.13.11 golang.org/x/tools v0.19.0 ) diff --git a/go.sum b/go.sum index 80b84e2cc..aaf7fa1bb 100644 --- a/go.sum +++ b/go.sum @@ -6,8 +6,8 @@ github.com/goplus/llgo v0.9.9 h1:sCM8ehOtuAEY/NQbJ4xAMRZhxEdDgilouWZpoaLiYrM= github.com/goplus/llgo v0.9.9/go.mod h1:udcq+s6tGOdhJq7I8fXPTv4qT2j17/KrlvtcJrMZAoM= github.com/goplus/mod v0.13.15 h1:IyneSjwm1VpwvHGz6hSHnFxZCuO6ULHcu74IAZcW9nw= github.com/goplus/mod v0.13.15/go.mod h1:invR72Rz2+qpOOsXqxz830MX8/aR2GDR2EAow/WgfHI= -github.com/qiniu/x v1.13.10 h1:J4Z3XugYzAq85SlyAfqlKVrbf05glMbAOh+QncsDQpE= -github.com/qiniu/x v1.13.10/go.mod h1:INZ2TSWSJVWO/RuELQROERcslBwVgFG7MkTfEdaQz9E= +github.com/qiniu/x v1.13.11 h1:zlFLY9zFXOwKEjx0SQXRBunhFjDVpEY+pRGL/4shd5U= +github.com/qiniu/x v1.13.11/go.mod h1:INZ2TSWSJVWO/RuELQROERcslBwVgFG7MkTfEdaQz9E= golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0= golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=