0% found this document useful (0 votes)
4 views2 pages

Handling .partial Files in Go Modules

The document outlines a series of commands and expected behaviors related to Go module management, specifically focusing on the 'go mod' commands and their interactions with module caching and verification. It demonstrates scenarios where modules are partially downloaded or corrupted, and how the system should respond to these situations, including error messages and verification failures. The document also includes a sample 'go.mod' file and a usage example for importing a module.

Uploaded by

tehlan.sanchit
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Handling .partial Files in Go Modules

The document outlines a series of commands and expected behaviors related to Go module management, specifically focusing on the 'go mod' commands and their interactions with module caching and verification. It demonstrates scenarios where modules are partially downloaded or corrupted, and how the system should respond to these situations, including error messages and verification failures. The document also includes a sample 'go.mod' file and a usage example for importing a module.

Uploaded by

tehlan.sanchit
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

# Download modules and populate [Link].

go get -modcacherw
exists $GOPATH/pkg/mod/[Link]/quote@v1.5.2/[Link]

# 'go mod verify' should fail if we delete a file.


go mod verify
rm $GOPATH/pkg/mod/[Link]/quote@v1.5.2/[Link]
! go mod verify

# Create a .partial file to simulate an failure extracting the zip file.


cp empty $GOPATH/pkg/mod/cache/download/[Link]/quote/@v/[Link]

# 'go mod verify' should not fail, since the module hasn't been completely
# ingested into the cache.
go mod verify

# 'go list' should not load packages from the directory.


# NOTE: the message "directory $dir outside main module or its selected
dependencies"
# is reported for directories not in the main module, active modules in the
# module cache, or local replacements. In this case, the directory is in the
# right place, but it's incomplete, so 'go list' acts as if it's not an
# active module.
! go list $GOPATH/pkg/mod/[Link]/quote@v1.5.2
stderr 'outside main module or its selected dependencies'

# 'go list -m' should not print the directory.


go list -m -f '{{.Dir}}' [Link]/quote
! stdout .

# 'go mod download' should re-extract the module and remove the .partial file.
go mod download -modcacherw [Link]/quote
! exists $GOPATH/pkg/mod/cache/download/[Link]/quote/@v/[Link]
exists $GOPATH/pkg/mod/[Link]/quote@v1.5.2/[Link]

# 'go list' should succeed.


go list $GOPATH/pkg/mod/[Link]/quote@v1.5.2
stdout '^[Link]/quote$'

# 'go list -m' should print the directory.


go list -m -f '{{.Dir}}' [Link]/quote
stdout 'pkg[/\\]mod[/\\][Link][/\\]quote@v1.5.2'

# go mod verify should fail if we delete a file.


go mod verify
rm $GOPATH/pkg/mod/[Link]/quote@v1.5.2/[Link]
! go mod verify

# 'go mod download' should not leave behind a directory or a .partial file
# if there is an error extracting the zip file.
rm $GOPATH/pkg/mod/[Link]/quote@v1.5.2
cp empty $GOPATH/pkg/mod/cache/download/[Link]/quote/@v/[Link]
! go mod download
stderr 'not a valid zip file'
! exists $GOPATH/pkg/mod/[Link]/quote@v1.5.2
! exists $GOPATH/pkg/mod/cache/download/[Link]/quote/@v/[Link]

-- [Link] --
module m
go 1.14

require [Link]/quote v1.5.2

-- [Link] --
package use

import _ "[Link]/quote"

-- empty --

You might also like