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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
Test of cross-package inlining.
The first case creates a new import,
the second reuses an existing one.
-- go.mod --
module testdata
go 1.12
-- a/a.go --
package a
// This comment does not migrate.
import (
"fmt"
"testdata/b"
)
// Nor this one.
func A() {
fmt.Println()
b.B1() //@ inline(re"B1", b1result)
b.B2() //@ inline(re"B2", b2result)
b.B3() //@ inline(re"B3", b3result)
}
-- b/b.go --
package b
import "testdata/c"
import "testdata/d"
import "fmt"
func B1() { c.C() }
func B2() { fmt.Println() }
func B3() { e.E() } // (note that "testdata/d" points to package e)
-- c/c.go --
package c
func C() {}
-- d/d.go --
package e // <- this package name intentionally mismatches the path
func E() {}
-- b1result --
package a
// This comment does not migrate.
import (
"fmt"
"testdata/b"
"testdata/c"
)
// Nor this one.
func A() {
fmt.Println()
c.C() //@ inline(re"B1", b1result)
b.B2() //@ inline(re"B2", b2result)
b.B3() //@ inline(re"B3", b3result)
}
-- b2result --
package a
// This comment does not migrate.
import (
"fmt"
"testdata/b"
)
// Nor this one.
func A() {
fmt.Println()
b.B1() //@ inline(re"B1", b1result)
fmt.Println() //@ inline(re"B2", b2result)
b.B3() //@ inline(re"B3", b3result)
}
-- b3result --
package a
// This comment does not migrate.
import (
"fmt"
"testdata/b"
e "testdata/d"
)
// Nor this one.
func A() {
fmt.Println()
b.B1() //@ inline(re"B1", b1result)
b.B2() //@ inline(re"B2", b2result)
e.E() //@ inline(re"B3", b3result)
}
|