cd main

# opt-out of default proxy service (ex: goes to github.com directly)
#setenv GOPROXY direct

# no proxy to use only what is available locally
setenv GOPROXY off

# without a go.mod
fail go mod init
contains stderr "go: cannot determine module path for source directory"

# suggests using "go mod tidy"
go mod init example.com

# cannot find module because goproxy=off, shouldn't it be able to find it locally?
fail go mod tidy
contains stderr "cannot find module"

fail go mod download golang.org/x/example
contains stderr "not a known dependency"

# TODO: should be able to solve this with goproxy=off if the module is already local
#go mod download golang.org/x/example@v0.0.0-20230901165430-d9923f6970e9

# set goproxy to empty to get default behaviour (golang.org)
setenv GOPROXY

go mod tidy
contains stderr "go: finding"
contains stderr "go: found"

# suggests using "go mod download"
go run main.go
contains stderr "cba"

#setenv script_keepwork true
#godebugtester run -verbose -srclines=false -work main.go
godebugtester run -sbr=false main.go
contains stdout "println(\"cba\")"
# inside the external pkg
contains stdout "len([99 98 97])"

-- main/main.go --
package main
//godebug:annotatepackage:golang.org/x/example/hello/reverse
import "golang.org/x/example/hello/reverse"
func main() {
	v:=reverse.String("abc")
	println(v)
}
