@@ -191,6 +191,9 @@ func (cs *CollectionSpec) Assign(to interface{}) error {
191
191
// LoadAndAssign loads Maps and Programs into the kernel and assigns them
192
192
// to a struct.
193
193
//
194
+ // Omitting Map/Program.Close() during application shutdown is an error.
195
+ // See the package documentation for details around Map and Program lifecycle.
196
+ //
194
197
// This function is a shortcut to manually checking the presence
195
198
// of maps and programs in a CollectionSpec. Consider using bpf2go
196
199
// if this sounds useful.
@@ -273,12 +276,20 @@ type Collection struct {
273
276
Maps map [string ]* Map
274
277
}
275
278
276
- // NewCollection creates a Collection from a specification.
279
+ // NewCollection creates a Collection from the given spec, creating and
280
+ // loading its declared resources into the kernel.
281
+ //
282
+ // Omitting Collection.Close() during application shutdown is an error.
283
+ // See the package documentation for details around Map and Program lifecycle.
277
284
func NewCollection (spec * CollectionSpec ) (* Collection , error ) {
278
285
return NewCollectionWithOptions (spec , CollectionOptions {})
279
286
}
280
287
281
- // NewCollectionWithOptions creates a Collection from a specification.
288
+ // NewCollectionWithOptions creates a Collection from the given spec using
289
+ // options, creating and loading its declared resources into the kernel.
290
+ //
291
+ // Omitting Collection.Close() during application shutdown is an error.
292
+ // See the package documentation for details around Map and Program lifecycle.
282
293
func NewCollectionWithOptions (spec * CollectionSpec , opts CollectionOptions ) (* Collection , error ) {
283
294
loader := newCollectionLoader (spec , & opts )
284
295
defer loader .cleanup ()
@@ -531,7 +542,11 @@ func (cl *collectionLoader) populateMaps() error {
531
542
return nil
532
543
}
533
544
534
- // LoadCollection parses an object file and converts it to a collection.
545
+ // LoadCollection reads an object file and creates and loads its declared
546
+ // resources into the kernel.
547
+ //
548
+ // Omitting Collection.Close() during application shutdown is an error.
549
+ // See the package documentation for details around Map and Program lifecycle.
535
550
func LoadCollection (file string ) (* Collection , error ) {
536
551
spec , err := LoadCollectionSpec (file )
537
552
if err != nil {
0 commit comments