# 'go get pkg' should not show a deprecation message for an unrelated module.
go get -d ./use/nothing
! stderr 'module.*is deprecated'

# 'go get pkg' should show a deprecation message for the module providing pkg.
go get -d example.com/deprecated/a
stderr '^go: module example.com/deprecated/a is deprecated: in example.com/deprecated/a@v1.9.0$'
go get -d example.com/deprecated/a@v1.0.0
stderr '^go: module example.com/deprecated/a is deprecated: in example.com/deprecated/a@v1.9.0$'

# 'go get pkg' should show a deprecation message for a module providing
# packages directly imported by pkg.
go get -d ./use/a
stderr '^go: module example.com/deprecated/a is deprecated: in example.com/deprecated/a@v1.9.0$'

# 'go get pkg' may show a deprecation message for an indirectly required module
# if it provides a package named on the command line.
go get -d ./use/b
! stderr 'module.*is deprecated'
go get -d local/use
! stderr 'module.*is deprecated'
go get -d example.com/deprecated/b
stderr '^go: module example.com/deprecated/b is deprecated: in example.com/deprecated/b@v1.9.0$'

# 'go get pkg' does not show a deprecation message for a module providing a
# directly imported package if the module is no longer deprecated in its
# latest version, even if the module is deprecated in its current version.
go get -d ./use/undeprecated
! stderr 'module.*is deprecated'

-- go.mod --
module m

go 1.17

require (
	example.com/deprecated/a v1.0.0
	example.com/undeprecated v1.0.0
	local v0.0.0
)

replace local v0.0.0 => ./local
-- use/nothing/nothing.go --
package nothing
-- use/a/a.go --
package a

import _ "example.com/deprecated/a"
-- use/b/b.go --
package b

import _ "local/use"
-- use/undeprecated/undeprecated.go --
package undeprecated

import _ "example.com/undeprecated"
-- local/go.mod --
module local

go 1.17

require example.com/deprecated/b v1.0.0
-- local/use/use.go --
package use

import _ "example.com/deprecated/b"
