| 1 |
# Test a replacement with an absolute path (so the path isn't |
| 2 |
# cleaned by having filepath.Abs called on it). This checks |
| 3 |
# whether the modindex logic cleans the modroot path before using |
| 4 |
# it. |
| 5 |
|
| 6 |
[!GOOS:windows] skip |
| 7 |
[short] skip |
| 8 |
|
| 9 |
go run print_go_mod.go # use this program to write a go.mod with an absolute path |
| 10 |
cp stdout go.mod |
| 11 |
|
| 12 |
go list -modfile=go.mod all |
| 13 |
-- print_go_mod.go -- |
| 14 |
//go:build ignore |
| 15 |
package main |
| 16 |
|
| 17 |
import ( |
| 18 |
"fmt" |
| 19 |
"os" |
| 20 |
) |
| 21 |
|
| 22 |
func main() { |
| 23 |
work := os.Getenv("WORK") |
| 24 |
fmt.Printf(`module example.com/mod |
| 25 |
|
| 26 |
require b.com v0.0.0 |
| 27 |
|
| 28 |
replace b.com => %s\gopath\src/modb |
| 29 |
`, work) |
| 30 |
} |
| 31 |
-- a.go -- |
| 32 |
package a |
| 33 |
|
| 34 |
import _ "b.com/b" |
| 35 |
-- modb/go.mod -- |
| 36 |
module b.com |
| 37 |
-- modb/b/b.go -- |
| 38 |
package b |