io.go
func ReadLine(reader io.Reader) (line string, err error) {
	buffer := bytes.NewBuffer(make([]byte, 0, 4096))
	p := make([]byte, 1)
	for {
		var n int
		n, err = reader.Read(p)
		if err != nil || p[0] == '\n' {
			break
		}
		if n > 0 {
			buffer.WriteByte(p[0])
		}
	}
	data := buffer.Bytes()
	if len(data) > 0 && data[len(data)-1] == '\r' {
		data = data[:len(data)-1]
	}
	return string(data), err
}
func ReadLine(reader io.Reader) (line string, err error) {
	buffer := bytes.NewBuffer(make([]byte, 0, 4096))
	p := make([]byte, 1)
	for {
		var n int
		n, err = reader.Read(p)
		if err != nil || p[0] == '\n' {
			break
		}
		if n > 0 {
			buffer.WriteByte(p[0])
		}
	}
	data := buffer.Bytes()
	if len(data) > 0 && data[len(data)-1] == '\r' {
		data = data[:len(data)-1]
	}
	return string(data), err
}
func ReadLine ( reader io . Reader ) ( line string , err error ) { buffer := bytes . NewBuffer ( make ( [ ] byte , 0 , 4096 ) ) p := make ( [ ] byte , 1 ) for { var n int n , err = reader . Read ( p ) if err != nil || p [ 0 ] == '\n' { break } if n > 0 { buffer . WriteByte ( p [ 0 ] ) } } data := buffer . Bytes ( ) if len ( data ) > 0 && data [ len ( data ) - 1 ] == '\r' { data = data [ : len ( data ) - 1 ] } return string ( data ) , err }
// ReadLine reads unbuffered until a newline '\n' byte and removes
// an optional carriege return '\r' at the end of the line.
// In case of an error, the string up to the error is returned.
ReadLine reads unbuffered until a newline \ n byte and removes an optional carriege return \ r at the end of the line . In case of an error the string up to the error is returned .