go list tool
stdout example.com/foo/cmd
stdout example.com/dependency/cmd/bar
go list all
stdout example.com/foo/cmd
stdout example.com/foo/lib
stdout example.com/dependency/cmd/bar

cd workspace
go list tool
stdout example.com/foo/cmd
stdout example.com/dependency/cmd/bar
stdout example.com/dependency/cmd/baz
go list all
stdout example.com/foo/cmd
stdout example.com/foo/lib
stdout example.com/other
stdout example.com/dependency/cmd/bar
stdout example.com/dependency/cmd/baz

cd ../invalid_path
! go list all
stderr 'malformed tool path'

-- go.mod --
module example.com/foo

go 1.24

tool example.com/foo/cmd/eg
tool example.com/dependency/cmd/bar

replace example.com/dependency => ./dependency

require example.com/dependency v1.0.0

-- lib/main.go --
package lib

-- cmd/eg/main.go --
package main

func main(){}

-- dependency/go.mod --
module example.com/dependency

go 1.24
-- dependency/cmd/bar/main.go --
package main

func main(){}
-- dependency/cmd/baz/main.go --
package main

func main() {}
-- other/go.mod --
module example.com/other

go 1.24

tool example.com/dependency/cmd/baz

replace example.com/dependency => ../dependency

require example.com/dependency v1.0.0
-- other/lib.go --
package other
-- workspace/go.work --
go 1.24

use (
    ../
    ../other
)

-- invalid_path/go.mod --
module example.com/invalid_path

go 1.24

tool ./invalid_path
