mirror of
https://gitee.com/johng/gf
synced 2026-06-30 19:17:30 +08:00
50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
// Copyright 2017 gf Author(https://gitee.com/johng/gf). All Rights Reserved.
|
||
//
|
||
// This Source Code Form is subject to the terms of the MIT License.
|
||
// If a copy of the MIT was not distributed with this file,
|
||
// You can obtain one at https://gitee.com/johng/gf.
|
||
|
||
// 其他工具包
|
||
package gutil
|
||
|
||
// 便利数组查找字符串索引位置,如果不存在则返回-1,使用完整遍历查找
|
||
func StringSearch (a []string, s string) int {
|
||
for i, v := range a {
|
||
if s == v {
|
||
return i
|
||
}
|
||
}
|
||
return -1
|
||
}
|
||
|
||
// 判断字符串是否在数组中
|
||
func StringInArray (a []string, s string) bool {
|
||
return StringSearch(a, s) != -1
|
||
}
|
||
|
||
// 判断给定字符是否小写
|
||
func IsLetterLower(b byte) bool {
|
||
if b >= byte('a') && b <= byte('z') {
|
||
return true
|
||
}
|
||
return false
|
||
}
|
||
|
||
// 判断给定字符是否大写
|
||
func IsLetterUpper(b byte) bool {
|
||
if b >= byte('A') && b <= byte('Z') {
|
||
return true
|
||
}
|
||
return false
|
||
}
|
||
|
||
// 判断锁给字符串是否为数字
|
||
func IsNumeric(s string) bool {
|
||
for i := 0; i < len(s); i++ {
|
||
if s[i] < byte('0') && s[i] > byte('9') {
|
||
return false
|
||
}
|
||
}
|
||
return true
|
||
}
|