const ( // MaxZipFile is the maximum size in bytes of a module zip file. The // go command will report an error if either the zip file or its extracted // content is larger than this. MaxZipFile = 500 << 20 // MaxGoMod is the maximum size in bytes of a go.mod file within a // module zip file. MaxGoMod = 16 << 20 // MaxLICENSE is the maximum size in bytes of a LICENSE file within a // module zip file. MaxLICENSE = 16 << 20 )
func Create(w io.Writer, m module.Version, files []File) (err error)
Create builds a zip archive for module m from an abstract list of files and writes it to w.
Create verifies the restrictions described in the package documentation and should not produce an archive that Unzip cannot extract. Create does not include files in the output archive if they don't belong in the module zip. In particular, Create will not include files in modules found in subdirectories, most files in vendor directories, or irregular files (such as symbolic links) in the output archive.
func CreateFromDir(w io.Writer, m module.Version, dir string) (err error)
CreateFromDir creates a module zip file for module m from the contents of a directory, dir. The zip content is written to w.
CreateFromDir verifies the restrictions described in the package documentation and should not produce an archive that Unzip cannot extract. CreateFromDir does not include files in the output archive if they don't belong in the module zip. In particular, CreateFromDir will not include files in modules found in subdirectories, most files in vendor directories, or irregular files (such as symbolic links) in the output archive.
func Unzip(dir string, m module.Version, zipFile string) (err error)
Unzip extracts the contents of a module zip file to a directory.
Unzip checks all restrictions listed in the package documentation and returns an error if the zip archive is not valid. In some cases, files may be written to dir before an error is returned (for example, if a file's uncompressed size does not match its declared size).
dir may or may not exist: Unzip will create it and any missing parent directories if it doesn't exist. If dir exists, it must be empty.
File provides an abstraction for a file in a directory, zip, or anything else that looks like a file.
type File interface { // Path returns a clean slash-separated relative path from the module root // directory to the file. Path() string // Lstat returns information about the file. If the file is a symbolic link, // Lstat returns information about the link itself, not the file it points to. Lstat() (os.FileInfo, error) // Open provides access to the data within a regular file. Open may return // an error if called on a directory or symbolic link. Open() (io.ReadCloser, error) }