Skip to content

Commit 16505d1

Browse files
tdauditi-mo
authored andcommitted
feat : Add LoadSplitSpec function
Similarly to LoadSpec, LoadSplitSpec could make an easier use of split-BTF files Signed-off-by: Tristan d'Audibert <[email protected]>
1 parent 321bac1 commit 16505d1

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

btf/btf.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,20 @@ func (s *Spec) TypeByName(name string, typ interface{}) error {
500500
return nil
501501
}
502502

503+
// LoadSplitSpec loads split BTF from the given file.
504+
//
505+
// Types from base are used to resolve references in the split BTF.
506+
// The returned Spec only contains types from the split BTF, not from the base.
507+
func LoadSplitSpec(file string, base *Spec) (*Spec, error) {
508+
fh, err := os.Open(file)
509+
if err != nil {
510+
return nil, err
511+
}
512+
defer fh.Close()
513+
514+
return LoadSplitSpecFromReader(fh, base)
515+
}
516+
503517
// LoadSplitSpecFromReader loads split BTF from a reader.
504518
//
505519
// Types from base are used to resolve references in the split BTF.

0 commit comments

Comments
 (0)