// ReadFirstLine ...
967667
func ReadFirstLine(s string, isIgnoreLeadingEmptyLines bool) string {
	scanner := bufio.NewScanner(strings.NewReader(s))
	firstLine := ""
	for scanner.Scan() {
		firstLine = scanner.Text()
		if !isIgnoreLeadingEmptyLines || firstLine != "" {
			break
		}
	}
	return firstLine
}
1151582
func readLines(resp *http.Response) (lines []string, err error) {
	defer drainAndClose(resp.Body, &err)
	reader := bufio.NewReader(resp.Body)
	buffer := bytes.NewBuffer(make([]byte, 0, 128))
	var part []byte
	var prefix bool
	for {
		if part, prefix, err = reader.ReadLine(); err != nil {
			break
		}
		buffer.Write(part)
		if !prefix {
			lines = append(lines, buffer.String())
			buffer.Reset()
		}
	}
	if err == io.EOF {
		err = nil
	}
	return
}
857525
func ReadLines(fileName string) ([]string, error) {
	file, err := os.Open(fileName)
	if err != nil {
		return nil, err
	}
	defer file.Close()

	scanner := bufio.NewScanner(file)
	var lines []string
	for scanner.Scan() {
		lines = append(lines, scanner.Text())
	}
	return lines, scanner.Err()
}
674944
func firstFile(tr *tar.Reader) ([]byte, error) {
	if _, err := tr.Next(); err != nil {
		return nil, err
	}

	var buf bytes.Buffer
	if _, err := io.Copy(&buf, tr); err != nil {
		return nil, err
	}

	return buf.Bytes(), nil
}
635043
func (r *Reader) ReadLine() (line []byte, err error) {

	// Sets r.idx to first \n or \r, or -1 if not found.
	scan := func() {
		end := r.n
		i1 := bytes.IndexByte(r.buf[r.p:end], '\n')
		if i1 >= 0 {
			end = r.p + i1
		}
		i2 := bytes.IndexByte(r.buf[r.p:end], '\r')
		if i2 >= 0 {
			r.idx = r.p + i2
		} else if i1 >= 0 {
			r.idx = r.p + i1
		} else {
			r.idx = -1
		}
	}

	// Fills buffer if no \n or \r found and no error yet,
	// and then rescans for first \n or \r.
	fill := func() {
		if (r.idx < 0 || r.idx == r.n - 1) && r.err == nil {
			if r.p > 0 {
				// make room
				if r.p < r.n {
					copy(r.buf, r.buf[r.p:r.n])
				}
				r.n -= r.p
				r.p = 0
			}
			if r.n < len(r.buf) {
				var i int
				i, r.err = r.rd.Read(r.buf[r.n:])
				r.n += i
			}
			scan()
		}
	}

	lines := make([][]byte, 0)
	beginning := true
	for {

		fill()

		// if at beginning of line, skip EOL of previous line
		if beginning {
			var c byte
			for i := 0; i < 2; i++ {
				// 1 or 2 times \r or \n, but not \r\r or \n\n
				if r.idx == r.p && r.buf[r.p] != c {
					c = r.buf[r.p]
					r.p += 1
					scan() // reset r.idx
				} else {
					break
				}
			}
			fill()
			beginning = false
		}

		// if error and no more unscanned data, return saved parts if they exist, else return error
		if r.p == r.n && r.err != nil {
			if len(lines) > 0 {
				return buildline(lines, r.buf[0:0]), nil
			} else {
				return r.buf[0:0], r.err
			}
		}

		if r.p < r.n {
			if r.idx < 0 { // no EOL found
				buf := make([]byte, r.n-r.p)
				copy(buf, r.buf[r.p:r.n])
				lines = append(lines, buf)
				r.p = r.n
			} else { // EOL found
				p := r.p
				r.p = r.idx
				return buildline(lines, r.buf[p:r.p]), nil
			}
		}

	}
	panic("not reached")
}
267266
func (c *chunkedSeq) ChunkedFirst() iseq.Chunk {
	return newArrayChunk2(c.node, c.offset)
}
1215130
func (t *tree) FindFirst(f func(v interface{}) (bool, error)) Changer {
	n, err := t.container.root.findFirst(func(fn *node) (bool, error) {
		return f(fn.content.value())
	})
	return &changer{n, err}
}
424035
func (t *stringTree) FindFirst(f func(v string) (bool, error)) StringChanger {
	n, err := t.container.root.findFirst(func(fn *node) (bool, error) {
		return f(fn.content.value().(string))
	})
	return &stringChanger{n, err}
}
778403
func (ctx *compctx) ErrorLine() int {
	var n int
	fmt.Sscanf(ctx.Error(), "Error > stdin:%d", &n)
	return n
}
345788
func (con *Connection) SetReadDeadline(t time.Time) error {
	return con.connection.SetReadDeadline(t)
}
636703
func (q *LinkedBlockingDeque) PutFirst(ctx context.Context, e interface{}) {
	if e == nil {
		return
	}
	q.lock.Lock()
	defer q.lock.Unlock()
	for !q.linkFirst(e) {
		q.notFull.Wait(ctx)
	}
}
390152
func (s *SkipList) SeekToFirst() Iterator {
	if s.length == 0 {
		return nil
	}

	current := s.header.next()

	return &iter{
		current: current,
		key:     current.key,
		list:    s,
		value:   current.value,
	}
}
364721
func scanLinesFromFile(filename string) ([]string, error) {
	var targetsInput io.Reader
	if filename == "-" {
		targetsInput = os.Stdin
	} else if filename == "" {
		return nil, fmt.Errorf("you must specify an list of resources to idle")
	} else {
		inputFile, err := os.Open(filename)
		if err != nil {
			return nil, err
		}
		defer inputFile.Close()
		targetsInput = inputFile
	}

	lines := []string{}

	// grab the raw resources from the file
	lineScanner := bufio.NewScanner(targetsInput)
	for lineScanner.Scan() {
		line := lineScanner.Text()
		if line == "" {
			// skip empty lines
			continue
		}
		lines = append(lines, line)
	}
	if err := lineScanner.Err(); err != nil {
		return nil, err
	}

	return lines, nil
}
68445
func (fu fileUtil) ReadByLines(filePath string, handler func(line string) error) error {
	var f *os.File
	var err error
	if f, err = os.Open(filePath); err == nil {
		defer f.Close()
		var line string
		scanner := bufio.NewScanner(f)
		for scanner.Scan() {
			line = scanner.Text()
			err = handler(line)
			if err != nil {
				return err
			}
		}
	}
	return err

}
849496
func Readlines(reader io.Reader) (generator chan []byte) {
	generator = make(chan []byte)
	go func() {
		defer close(generator)
		lreader := bufio.NewReader(reader)
		for line, isPrefix, err := lreader.ReadLine(); err != io.EOF; {
			fullLine := make([]byte, len(line))
			copy(fullLine, line)
			for isPrefix == true {
				line, isPrefix, err = lreader.ReadLine()
				fullLine = append(fullLine, line...)
			}
			generator <- fullLine
			line, isPrefix, err = lreader.ReadLine()
		}
	}()
	return generator
}
930178
func (this *IntErrs) GetFirstErr() (err error) {
	for _, v := range *this {
		if nil != v.E {
			return v.E
		}
	}
	return nil
}
376674
func (e *FSTEnum) pushFirst() (err error) {
	arc := e.arcs[e.upto]
	assert(arc != nil)

	for {
		e.output[e.upto] = e.fst.outputs.Add(e.output[e.upto-1], arc.Output)
		if arc.Label == FST_END_LABEL {
			// final node
			break
		}
		// fmt.Printf("  pushFirst label=%c upto=%v output=%v\n",
		// 	rune(arc.Label), e.upto, e.fst.outputs.outputToString(e.output[e.upto]))
		e.spi.setCurrentLabel(arc.Label)
		e.incr()

		nextArc := e.Arc(e.upto)
		if _, err = e.fst.readFirstTargetArc(arc, nextArc, e.fstReader); err != nil {
			return
		}
		arc = nextArc
	}
	return nil
}