You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
542 B
32 lines
542 B
package Test
|
|
|
|
import (
|
|
"bufio"
|
|
"fmt"
|
|
"io"
|
|
"os"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
//白名单数组
|
|
var WhiteArray []string
|
|
func TestReadLine2(t *testing.T) {
|
|
f, err := os.Open("../Config/White.txt")
|
|
if err != nil {
|
|
fmt.Println("没有找到白名单文件!")
|
|
}
|
|
buf := bufio.NewReader(f)
|
|
for {
|
|
line, err := buf.ReadString('\n')
|
|
line = strings.TrimSpace(line)
|
|
if strings.Index(line, "#") < 0 && len(line) > 0 {
|
|
WhiteArray = append(WhiteArray, line)
|
|
}
|
|
if err != nil || io.EOF == err {
|
|
break
|
|
}
|
|
}
|
|
fmt.Println(WhiteArray)
|
|
}
|
|
|