func ContainsHeader()

in licensing/license.go [63:92]


func ContainsHeader(r io.Reader, headerLines []string) bool {
	var scanner = bufio.NewScanner(r)
	var i int

	buf := bufPool.Get().([]byte)
	defer bufPool.Put(buf)
	scanner.Buffer(buf, defaulBufSize)

	for i = 0; scanner.Scan(); i++ {
		line := scanner.Bytes()

		// end of license, break out of the loop
		if i == len(headerLines) {
			break
		}

		// compare line by line without storing the whole file
		// in memory
		if !bytes.Equal(line, []byte(headerLines[i])) {
			return false
		}
	}

	// file is shorter than license
	if i < len(headerLines) {
		return false
	}

	return true
}