var downloadCache … var ErrToolchain … // Download downloads the specific module version to the // local download cache and returns the name of the directory // corresponding to the root of the module's file tree. func Download(ctx context.Context, mod module.Version) (dir string, err error) { … } func download(ctx context.Context, mod module.Version) (dir string, err error) { … } var downloadZipCache … // DownloadZip downloads the specific module version to the // local zip cache and returns the name of the zip file. func DownloadZip(ctx context.Context, mod module.Version) (zipfile string, err error) { … } func downloadZip(ctx context.Context, mod module.Version, zipfile string) (err error) { … } // hashZip reads the zip file opened in f, then writes the hash to ziphashfile, // overwriting that file if it exists. // // If the hash does not match go.sum (or the sumdb if enabled), hashZip returns // an error and does not write ziphashfile. func hashZip(mod module.Version, zipfile, ziphashfile string) (err error) { … } // makeDirsReadOnly makes a best-effort attempt to remove write permissions for dir // and its transitive contents. func makeDirsReadOnly(dir string) { … } // RemoveAll removes a directory written by Download or Unzip, first applying // any permission changes needed to do so. func RemoveAll(dir string) error { … } var GoSumFile … var WorkspaceGoSumFiles … type modSum … var goSum … type modSumStatus … // Reset resets globals in the modfetch package, so previous loads don't affect // contents of go.sum files. func Reset() { … } // initGoSum initializes the go.sum data. // The boolean it returns reports whether the // use of go.sum is now enabled. // The goSum lock must be held. func initGoSum() (bool, error) { … } func readGoSumFile(dst map[module.Version][]string, file string) (bool, error) { … } const emptyGoModHash … // readGoSum parses data, which is the content of file, // and adds it to goSum.m. The goSum lock must be held. func readGoSum(dst map[module.Version][]string, file string, data []byte) { … } // HaveSum returns true if the go.sum file contains an entry for mod. // The entry's hash must be generated with a known hash algorithm. // mod.Version may have a "/go.mod" suffix to distinguish sums for // .mod and .zip files. func HaveSum(mod module.Version) bool { … } // RecordedSum returns the sum if the go.sum file contains an entry for mod. // The boolean reports true if an entry was found or // false if no entry found or two conflicting sums are found. // The entry's hash must be generated with a known hash algorithm. // mod.Version may have a "/go.mod" suffix to distinguish sums for // .mod and .zip files. func RecordedSum(mod module.Version) (sum string, ok bool) { … } // checkMod checks the given module's checksum and Go version. func checkMod(ctx context.Context, mod module.Version) { … } // goModSum returns the checksum for the go.mod contents. func goModSum(data []byte) (string, error) { … } // checkGoMod checks the given module's go.mod checksum; // data is the go.mod content. func checkGoMod(path, version string, data []byte) error { … } // checkModSum checks that the recorded checksum for mod is h. // // mod.Version may have the additional suffix "/go.mod" to request the checksum // for the module's go.mod file only. func checkModSum(mod module.Version, h string) error { … } // haveModSumLocked reports whether the pair mod,h is already listed in go.sum. // If it finds a conflicting pair instead, it calls base.Fatalf. // goSum.mu must be locked. func haveModSumLocked(mod module.Version, h string) bool { … } // addModSumLocked adds the pair mod,h to go.sum. // goSum.mu must be locked. func addModSumLocked(mod module.Version, h string) { … } // checkSumDB checks the mod, h pair against the Go checksum database. // It calls base.Fatalf if the hash is to be rejected. func checkSumDB(mod module.Version, h string) error { … } // Sum returns the checksum for the downloaded copy of the given module, // if present in the download cache. func Sum(ctx context.Context, mod module.Version) string { … } // isValidSum returns true if data is the valid contents of a zip hash file. // Certain critical files are written to disk by first truncating // then writing the actual bytes, so that if the write fails // the corrupt file should contain at least one of the null // bytes written by the truncate operation. func isValidSum(data []byte) bool { … } var ErrGoSumDirty … // WriteGoSum writes the go.sum file if it needs to be updated. // // keep is used to check whether a newly added sum should be saved in go.sum. // It should have entries for both module content sums and go.mod sums // (version ends with "/go.mod"). Existing sums will be preserved unless they // have been marked for deletion with TrimGoSum. func WriteGoSum(ctx context.Context, keep map[module.Version]bool, readonly bool) error { … } // TidyGoSum returns a tidy version of the go.sum file. // A missing go.sum file is treated as if empty. func TidyGoSum(keep map[module.Version]bool) (before, after []byte) { … } // tidyGoSum returns a tidy version of the go.sum file. // The goSum lock must be held. func tidyGoSum(data []byte, keep map[module.Version]bool) []byte { … } func sumInWorkspaceModulesLocked(m module.Version) bool { … } // TrimGoSum trims go.sum to contain only the modules needed for reproducible // builds. // // keep is used to check whether a sum should be retained in go.mod. It should // have entries for both module content sums and go.mod sums (version ends // with "/go.mod"). func TrimGoSum(keep map[module.Version]bool) { … } const goSumMismatch … const sumdbMismatch … const hashVersionMismatch … var HelpModuleAuth … var HelpPrivate …