strutil.go 411 B

1234567891011121314151617
  1. // Copyright 2020 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package strutil
  5. import (
  6. "unicode"
  7. )
  8. // ToUpperFirst returns s with only the first Unicode letter mapped to its upper case.
  9. func ToUpperFirst(s string) string {
  10. for i, v := range s {
  11. return string(unicode.ToUpper(v)) + s[i+1:]
  12. }
  13. return ""
  14. }