| Server IP : 217.160.0.212 / Your IP : 216.73.216.141 Web Server : Apache System : Linux www 6.18.51-i1-ampere #1196 SMP Fri Sep 11 20:43:55 CEST 2026 aarch64 User : sws1073854427 ( 1073854427) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /lib/go/src/cmd/go/testdata/script/ |
Upload File : |
# 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
go 1.17
require example.com/stack v1.0.0
-- go.sum --
example.com/stack v1.0.0 h1:IEDLeew5NytZ8vrgCF/QVem3H3SR3QMttdu9HfJvk9I=
example.com/stack v1.0.0/go.mod h1:7wFEbaV5e5O7wJ8aBdqQOR//UXppm/pwnwziMKViuI4=
-- main.go --
package main
import (
"fmt"
"example.com/stack"
)
func main() {
fmt.Println(stack.TopFile())
}