aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/testdata/script/mod_vendor_trimpath.txt
blob: 5451aa773c8b5ea4eb4fed7fb90954199a3427bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Check that when -trimpath and -mod=vendor are used together,
# paths in vendored packages are properly trimmed.
# Verifies golang.org/issue/36566.

[short] skip

# Only the main module has a root directory in vendor mode.
go mod vendor
go list -f {{.Module.Dir}} example.com/main
stdout $PWD
go list -f {{.Module.Dir}} example.com/stack
! stdout .

# The program prints a file name from a vendored package.
# Without -trimpath, the name should include the vendor directory.
go run main.go
stdout vendor

# With -trimpath, everything before the package path should be trimmed.
# As with -mod=mod, the version should appear as part of the module path.
go run -mod=vendor -trimpath main.go
stdout '^example.com/stack@v1.0.0/stack.go$'

# With pristinely vendored source code, a trimmed binary built from vendored
# code should have the same behavior as one build from the module cache.
go run -mod=mod -trimpath main.go
stdout '^example.com/stack@v1.0.0/stack.go$'

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

require example.com/stack v1.0.0

-- main.go --
package main

import (
  "fmt"

  "example.com/stack"
)

func main() {
  fmt.Println(stack.TopFile())
}