MCPcopy Create free account
hub / github.com/chainreactors/spray / LoadFileToSlice

Function LoadFileToSlice

pkg/utils.go:545–566  ·  view source on GitHub ↗
(filename string)

Source from the content-addressed store, hash-verified

543}
544
545func LoadFileToSlice(filename string) ([]string, error) {
546 var ss []string
547 if dicts, ok := Dicts[filename]; ok {
548 if files.IsExist(filename) {
549 logs.Log.Warnf("load and overwrite %s from preset", filename)
550 }
551 return dicts, nil
552 }
553 content, err := ioutil.ReadFile(filename)
554 if err != nil {
555 return nil, err
556 }
557
558 ss = strings.Split(strings.TrimSpace(string(content)), "\n")
559
560 // 统一windows与linux的回车换行差异
561 for i, word := range ss {
562 ss[i] = strings.TrimSpace(word)
563 }
564
565 return ss, nil
566}
567
568func LoadRuleAndCombine(filename []string) (string, error) {
569 var bs bytes.Buffer

Callers 2

BuildWordsMethod · 0.92
loadFileWithCacheFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected