1 go mod vendor
2 cmp vendor/example.com/a/samedir_embed.txt a/samedir_embed.txt
3 cmp vendor/example.com/a/subdir/embed.txt a/subdir/embed.txt
4 cmp vendor/example.com/a/subdir/test/embed.txt a/subdir/test/embed.txt
5 cmp vendor/example.com/a/subdir/test/xtest/embed.txt a/subdir/test/xtest/embed.txt
6
7 cd broken_no_matching_files
8 ! go mod vendor
9 stderr 'go: pattern foo.txt: no matching files found'
10
11 cd ../broken_bad_pattern
12 ! go mod vendor
13 stderr 'go: pattern ../foo.txt: invalid pattern syntax'
14
15 cd ../embed_go122
16 go mod vendor
17 cmp vendor/example.com/a/samedir_embed.txt ../a/samedir_embed.txt
18 cmp vendor/example.com/a/subdir/embed.txt ../a/subdir/embed.txt
19 ! exists vendor/example.com/a/subdir/test/embed.txt
20 ! exists vendor/example.com/a/subdir/test/xtest/embed.txt
21 -- embed_go122/go.mod --
22 module example.com/foo
23 go 1.22
24
25 require (
26 example.com/a v0.1.0
27 )
28
29 replace (
30 example.com/a v0.1.0 => ../a
31 )
32 -- embed_go122/foo.go --
33 package main
34
35 import (
36 "fmt"
37
38 "example.com/a"
39 )
40
41 func main() {
42 fmt.Println(a.Str())
43 }
44
45 # matchPotentialSourceFile prunes out tests and unbuilt code.
46 # Make sure that they are vendored if they are embedded files.
47 cd ../embed_unbuilt
48 go mod vendor
49 cmp vendor/example.com/dep/unbuilt.go dep/unbuilt.go
50 cmp vendor/example.com/dep/dep_test.go dep/dep_test.go
51 ! exists vendor/example.com/dep/not_embedded_unbuilt.go
52 ! exists vendor/example.com/dep/not_embedded_dep_test.go
53 -- go.mod --
54 module example.com/foo
55 go 1.16
56
57 require (
58 example.com/a v0.1.0
59 )
60
61 replace (
62 example.com/a v0.1.0 => ./a
63 )
64 -- foo.go --
65 package main
66
67 import (
68 "fmt"
69
70 "example.com/a"
71 )
72
73 func main() {
74 fmt.Println(a.Str())
75 }
76 -- a/go.mod --
77 module example.com/a
78 -- a/a.go --
79 package a
80
81 import _ "embed"
82
83 //go:embed samedir_embed.txt
84 var sameDir string
85
86 //go:embed subdir/embed.txt
87 var subDir string
88
89 func Str() string {
90 return sameDir + subDir
91 }
92 -- a/a_test.go --
93 package a
94
95 import _ "embed"
96
97 //go:embed subdir/test/embed.txt
98 var subderTest string
99 -- a/a_x_test.go --
100 package a_test
101
102 import _ "embed"
103
104 //go:embed subdir/test/xtest/embed.txt
105 var subdirXtest string
106 -- a/samedir_embed.txt --
107 embedded file in same directory as package
108 -- a/subdir/embed.txt --
109 embedded file in subdirectory of package
110 -- a/subdir/test/embed.txt --
111 embedded file of test in subdirectory of package
112 -- a/subdir/test/xtest/embed.txt --
113 embedded file of xtest in subdirectory of package
114 -- broken_no_matching_files/go.mod --
115 module example.com/broken
116 go 1.16
117
118 require (
119 example.com/brokendep v0.1.0
120 )
121
122 replace (
123 example.com/brokendep v0.1.0 => ./brokendep
124 )
125 -- broken_no_matching_files/f.go --
126 package broken
127
128 import _ "example.com/brokendep"
129
130 func F() {}
131 -- broken_no_matching_files/brokendep/go.mod --
132 module example.com/brokendep
133 go 1.16
134 -- broken_no_matching_files/brokendep/f.go --
135 package brokendep
136
137 import _ "embed"
138
139 //go:embed foo.txt
140 var foo string
141 -- broken_bad_pattern/go.mod --
142 module example.com/broken
143 go 1.16
144
145 require (
146 example.com/brokendep v0.1.0
147 )
148
149 replace (
150 example.com/brokendep v0.1.0 => ./brokendep
151 )
152 -- broken_bad_pattern/f.go --
153 package broken
154
155 import _ "example.com/brokendep"
156
157 func F() {}
158 -- broken_bad_pattern/brokendep/go.mod --
159 module example.com/brokendep
160 go 1.16
161 -- broken_bad_pattern/brokendep/f.go --
162 package brokendep
163
164 import _ "embed"
165
166 //go:embed ../foo.txt
167 var foo string
168 -- embed_unbuilt/go.mod --
169 module example.com/foo
170 go 1.16
171
172 require (
173 example.com/dep v0.1.0
174 )
175
176 replace (
177 example.com/dep v0.1.0 => ./dep
178 )
179 -- embed_unbuilt/foo.go --
180 package a
181
182 import _ "example.com/dep"
183
184 func F() {}
185 -- embed_unbuilt/dep/go.mod --
186 module example.com/dep
187 go 1.16
188 -- embed_unbuilt/dep/dep.go --
189 package dep
190
191 import _ "embed"
192
193 //go:embed unbuilt.go
194 var unbuilt string
195
196 //go:embed dep_test.go
197 var depTest string
198 -- embed_unbuilt/dep/unbuilt.go --
199 // +build ignore
200
201 package dep
202 -- embed_unbuilt/dep/not_embedded_unbuilt.go --
203 // +build ignore
204
205 package dep
206 -- embed_unbuilt/dep/dep_test.go --
207 package dep
208 -- embed_unbuilt/dep/not_embedded_dep_test.go --
209 package dep
210
View as plain text