file.go
func FileGetLines(filenameOrURL string, timeout ...time.Duration) (lines []string, err error) {
	data, err := FileGetBytes(filenameOrURL, timeout...)
	if err != nil {
		return nil, err
	}

	lastR := -1
	lastN := -1

	for i, c := range data {
		if c == '\r' {
			l := string(data[lastN+1 : i])
			lines = append(lines, l)
			lastR = i
		}
		if c == '\n' {
			if i != lastR+1 {
				l := string(data[lastN+1 : i])
				lines = append(lines, l)
			}
			lastN = i
		}
	}
	l := string(data[lastN+1:])
	lines = append(lines, l)

	return lines, nil
}
func FileGetLines(filenameOrURL string, timeout ...time.Duration) (lines []string, err error) {
	data, err := FileGetBytes(filenameOrURL, timeout...)
	if err != nil {
		return nil, err
	}

	lastR := -1
	lastN := -1

	for i, c := range data {
		if c == '\r' {
			l := string(data[lastN+1 : i])
			lines = append(lines, l)
			lastR = i
		}
		if c == '\n' {
			if i != lastR+1 {
				l := string(data[lastN+1 : i])
				lines = append(lines, l)
			}
			lastN = i
		}
	}
	l := string(data[lastN+1:])
	lines = append(lines, l)

	return lines, nil
}
func FileGetLines ( filenameOrURL string , timeout ... time . Duration ) ( lines [ ] string , err error ) { data , err := FileGetBytes ( filenameOrURL , timeout ... ) if err != nil { return nil , err } lastR := - 1 lastN := - 1 for i , c := range data { if c == '\r' { l := string ( data [ lastN + 1 : i ] ) lines = append ( lines , l ) lastR = i } if c == '\n' { if i != lastR + 1 { l := string ( data [ lastN + 1 : i ] ) lines = append ( lines , l ) } lastN = i } } l := string ( data [ lastN + 1 : ] ) lines = append ( lines , l ) return lines , nil }
// FileGetLines returns a string slice with the text lines of filenameOrURL.
// The lines can be separated by \n or \r\n.
FileGetLines returns a string slice with the text lines of filenameOrURL . The lines can be separated by \ n or \ r \ n .