We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0ccdee2 commit 8a0ac3eCopy full SHA for 8a0ac3e
internal/internal.go
@@ -286,6 +286,24 @@ func ToFile(n ast.Node) *ast.File {
286
}
287
288
289
+// ToStruct gets the non-preamble declarations of a file and puts them in a
290
+// struct.
291
+func ToStruct(f *ast.File) *ast.StructLit {
292
+ start := 0
293
+ for i, d := range f.Decls {
294
+ switch d.(type) {
295
+ case *ast.Package, *ast.ImportDecl:
296
+ start = i + 1
297
+ case *ast.Attribute, *ast.CommentGroup:
298
+ default:
299
+ break
300
+ }
301
302
+ s := ast.NewStruct()
303
+ s.Elts = f.Decls[start:]
304
+ return s
305
+}
306
+
307
func IsBulkField(d ast.Decl) bool {
308
if f, ok := d.(*ast.Field); ok {
309
if _, ok := f.Label.(*ast.ListLit); ok {
0 commit comments