Copyright 2019 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Package fetch provides a way to fetch modules from a proxy.
package fetch

import (
	
	
	
	

	
	
)
extractReadmesFromZip returns the file path and contents of all files from r that are README files.
func (,  string,  *zip.Reader) ( []*internal.Readme,  error) {
	defer derrors.Wrap(&, "extractReadmesFromZip(ctx, %q, %q, r)", , )
The key is the README directory. Since we only store one README file per directory, we use this below to prioritize READMEs in markdown.
	 := map[string]*internal.Readme{}
	for ,  := range .File {
		if isReadme(.Name) {
			if .UncompressedSize64 > MaxFileSize {
				return nil, fmt.Errorf("file size %d exceeds max limit %d", .UncompressedSize64, MaxFileSize)
			}
			,  := readZipFile(, MaxFileSize)
			if  != nil {
				return nil, 
			}

			 := strings.TrimPrefix(.Name, moduleVersionDir(, )+"/")
			 := path.Dir()
Prefer READMEs written in markdown, since we style these on the frontend.
				 := path.Ext(.Filepath)
				if  == ".md" ||  == ".markdown" {
					continue
				}
			}
			[] = &internal.Readme{
				Filepath: ,
				Contents: string(),
			}
		}
	}

	var  []*internal.Readme
	for ,  := range  {
		 = append(, )
	}
	return , nil
}

var excludedReadmeExts = map[string]bool{".go": true, ".vendor": true}
isReadme reports whether file is README or if the base name of file, with or without the extension, is equal to expectedFile. README.go files will return false. It is case insensitive. It operates on '/'-separated paths.
func ( string) bool {
	const  = "README"
	 := path.Base()
	 := path.Ext()
	return !excludedReadmeExts[] && strings.EqualFold(strings.TrimSuffix(, ), )