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

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

View as plain text