...

Text file src/cmd/go/testdata/script/vendor_outside_module.txt

Documentation: cmd/go/testdata/script

     1# baz.go (importing just fmt) works with -mod=mod,  -mod=vendor.
     2go build -x -mod=mod my-module/vendor/example.com/another-module/foo/bar/baz.go
     3go build -x -mod=readonly my-module/vendor/example.com/another-module/foo/bar/baz.go
     4go build -x -mod=vendor my-module/vendor/example.com/another-module/foo/bar/baz.go
     5
     6# baz_with_outside_dep.go (with a non-std dependency) works with -mod=mod
     7# but not with -mod=readonly and -mod=vendor.
     8go build -x -mod=mod my-module/vendor/example.com/another-module/foo/bar/baz_with_outside_dep.go
     9! go build -x -mod=readonly my-module/vendor/example.com/another-module/foo/bar/baz_with_outside_dep.go
    10stderr 'no required module provides package rsc.io/quote'
    11! go build -x -mod=vendor my-module/vendor/example.com/another-module/foo/bar/baz_with_outside_dep.go
    12stderr 'no required module provides package rsc.io/quote'
    13
    14-- my-module/go.mod --
    15module example.com/my-module
    16
    17go 1.20
    18-- my-module/vendor/example.com/another-module/foo/bar/baz.go --
    19package main
    20
    21import "fmt"
    22
    23func main() {
    24	fmt.Println("hello, world.")
    25}
    26-- my-module/vendor/example.com/another-module/foo/bar/baz_with_outside_dep.go --
    27package main
    28
    29import (
    30    "fmt"
    31    "rsc.io/quote"
    32)
    33
    34func main() {
    35	fmt.Println(quote.Hello())
    36}

View as plain text