Debian Codegraph @

internal/refactor/inline/testdata/crosspkg.txtar

raw
1 Test of cross-package inlining.
2 The first case creates a new import,
3 the second reuses an existing one.
4
5 -- go.mod --
6 module testdata
7 go 1.12
8
9 -- a/a.go --
10 package a
11
12 // This comment does not migrate.
13
14 import (
15 "fmt"
16 "testdata/b"
17 )
18
19 // Nor this one.
20
21 func A() {
22 fmt.Println()
23 b.B1() //@ inline(re"B1", b1result)
24 b.B2() //@ inline(re"B2", b2result)
25 b.B3() //@ inline(re"B3", b3result)
26 }
27
28 -- b/b.go --
29 package b
30
31 import "testdata/c"
32 import "testdata/d"
33 import "fmt"
34
35 func B1() { c.C() }
36 func B2() { fmt.Println() }
37 func B3() { e.E() } // (note that "testdata/d" points to package e)
38
39 -- c/c.go --
40 package c
41
42 func C() {}
43
44 -- d/d.go --
45 package e // <- this package name intentionally mismatches the path
46
47 func E() {}
48
49 -- b1result --
50 package a
51
52 // This comment does not migrate.
53
54 import (
55 "fmt"
56 "testdata/b"
57 "testdata/c"
58 )
59
60 // Nor this one.
61
62 func A() {
63 fmt.Println()
64 c.C() //@ inline(re"B1", b1result)
65 b.B2() //@ inline(re"B2", b2result)
66 b.B3() //@ inline(re"B3", b3result)
67 }
68
69 -- b2result --
70 package a
71
72 // This comment does not migrate.
73
74 import (
75 "fmt"
76 "testdata/b"
77 )
78
79 // Nor this one.
80
81 func A() {
82 fmt.Println()
83 b.B1() //@ inline(re"B1", b1result)
84 fmt.Println() //@ inline(re"B2", b2result)
85 b.B3() //@ inline(re"B3", b3result)
86 }
87 -- b3result --
88 package a
89
90 // This comment does not migrate.
91
92 import (
93 "fmt"
94 "testdata/b"
95 e "testdata/d"
96 )
97
98 // Nor this one.
99
100 func A() {
101 fmt.Println()
102 b.B1() //@ inline(re"B1", b1result)
103 b.B2() //@ inline(re"B2", b2result)
104 e.E() //@ inline(re"B3", b3result)
105 }