本文整理汇总了Golang中bytes.ToLower函数的典型用法代码### 示例。如果您正苦于以下问题:Golang ToLower函数的具体用法?Golang ToLower怎么用?Golang ToLower使用的例子?那么恭喜您, 这里精选的函数代码### 示例或许可以为您提供帮助。
在下文中一共展示了ToLower函数的20个代码### 示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码### 示例。
示例1: parseline
func parseline(line []byte, i int) (int, int, int, error) {
comma := bytes.Index(line, []byte{'#'})
if comma >= 0 {
line = line[0:comma]
}
if l := len(line); l < 4 {
return -1, -1, -1, fmt.Errorf("line %d length invalid: %d %q\n", i, l, line)
}
rl := bytes.TrimSpace(line)
rl = re_space.ReplaceAll(rl, []byte{' '})
chs := bytes.Split(rl, []byte{' '})
if len(chs) != 2 {
return -1, -1, -1,
fmt.Errorf("line %d has %d numbers: %s\n", i, len(chs), rl)
}
ret, err := strconv.ParseInt(string(bytes.ToLower(chs[0])), 0, 32)
if err != nil {
return -1, -1, -1,
fmt.Errorf("convert %q to int failed at line %d: %s\n", chs[0], i, err)
}
gb2312 := int(ret)
if gb2312 <= 0x7f {
return gb2312, gb2312, gb2312, fmt.Errorf("No need convert for ascii 0x%x\n", gb2312)
}
ret, err = strconv.ParseInt(string(bytes.ToLower(chs[1])), 0, 32)
if err != nil {
return -1, -1, -1,
fmt.Errorf("convert %q to int failed at line %d: %s\n", chs[1], i, err)
}
unicode := int(ret)
utf8 := unicode2utf8(unicode)
return gb2312, unicode, utf8, nil
}
开发者ID:ryancsq,项目名称:test,代码行数:34,代码来源:gb2312.go
示例2: Equals
// Equals reports whether a pattern is identical to another pattern.
func (c IgnoreCase) Equals(pat patterns.Pattern) bool {
c2, ok := pat.(IgnoreCase)
if ok && bytes.Equal(bytes.ToLower(c), bytes.ToLower(c2)) {
return true
}
return false
}
开发者ID:richardlehane,项目名称:siegfried,代码行数:8,代码来源:patterns.go
示例3: ParseIni
func ParseIni(reader io.Reader) (*Config, error) {
section, lastKey, cfg := "/", "", make(map[string]string)
firstLine, scanner := true, bufio.NewScanner(reader)
for scanner.Scan() {
s := scanner.Bytes()
if firstLine {
s = removeUtf8Bom(s)
firstLine = false
}
s = bytes.TrimSpace(s)
if len(s) == 0 || s[0] == '#' { // empty or comment
continue
}
if s[0] == '[' && s[len(s)-1] == ']' { // section
s = bytes.TrimSpace(s[1 : len(s)-1])
if len(s) >= 0 {
section = "/" + string(bytes.ToLower(s))
}
continue
}
k, v := "", ""
if i := bytes.IndexByte(s, '='); i != -1 {
k = string(bytes.ToLower(bytes.TrimSpace(s[:i])))
v = string(bytes.TrimSpace(s[i+1:]))
}
if len(k) > 0 {
lastKey = section + "/" + k
cfg[lastKey] = v
continue
} else if len(lastKey) == 0 {
continue
}
c, lv := byte(128), cfg[lastKey]
if len(lv) > 0 {
c = lv[len(lv)-1]
}
if len(v) == 0 { // empty value means a new line
cfg[lastKey] = lv + "\n"
} else if c < 128 && c != '-' && v[0] < 128 { // need a white space?
// not good enough, but should be ok in most cases
cfg[lastKey] = lv + " " + v
} else {
cfg[lastKey] = lv + v
}
}
if e := scanner.Err(); e != nil {
return nil, e
}
return &Config{data: cfg}, nil
}
开发者ID:ssor,项目名称:makeepub,代码行数:59,代码来源:config.go
示例4: PremiumUserHandle
// PremiumUserHandle user logs + replies
func PremiumUserHandle(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
nick := bytes.ToLower([]byte(vars["nick"]))
filter := func(line []byte) bool {
return bytes.Contains(bytes.ToLower(line), nick)
}
serveFilteredLogs(w, common.GetConfig().LogPath+"/"+vars["channel"]+"/"+vars["month"], filter)
}
开发者ID:slugalisk,项目名称:overrustlelogs,代码行数:9,代码来源:server.go
示例5: local_ac
func local_ac(view *view) ([]ac_proposal, int) {
var dups llrb_tree
var others llrb_tree
proposals := make([]ac_proposal, 0, 100)
prefix := view.cursor.word_under_cursor()
// update word caches
view.other_buffers(func(buf *buffer) {
buf.update_words_cache()
})
collect := func(ignorecase bool) {
words := view.collect_words([][]byte(nil), &dups, ignorecase)
for _, word := range words {
proposals = append(proposals, ac_proposal{
display: word,
content: word,
})
}
lprefix := prefix
if ignorecase {
lprefix = bytes.ToLower(prefix)
}
view.other_buffers(func(buf *buffer) {
buf.words_cache.walk(func(word []byte) {
lword := word
if ignorecase {
lword = bytes.ToLower(word)
}
if bytes.HasPrefix(lword, lprefix) {
ok := dups.insert_maybe(word)
if !ok {
return
}
others.insert_maybe(word)
}
})
})
others.walk(func(word []byte) {
proposals = append(proposals, ac_proposal{
display: word,
content: word,
})
})
others.clear()
}
collect(false)
if len(proposals) == 0 {
collect(true)
}
if prefix != nil {
return proposals, utf8.RuneCount(prefix)
}
return proposals, 0
}
开发者ID:magenbluten,项目名称:godit,代码行数:57,代码来源:autocomplete.go
最后编辑: kuteng 文档更新时间: 2021-08-23 19:14 作者:kuteng