func fetchLibraryWithDependencies()

in initialize.go [24:49]


func fetchLibraryWithDependencies(ctx context.Context, processed map[string]bool, lib LibraryReference, result *LibraryReferences) error {
	if processed[lib.String()] {
		return nil
	}
	f, err := lib.Fetch(ctx, hash(lib))
	if err != nil {
		return fmt.Errorf("FetchLibraryWithDependencies: error fetching library %s: %w", lib.String(), err)
	}
	pscl := processor.NewProcessorClient(f)
	libmeta, err := pscl.Metadata()
	if err != nil {
		return fmt.Errorf("FetchLibraryWithDependencies: error getting metadata for library %s: %w", lib.String(), err)
	}
	meta := NewMetadata(libmeta, lib)
	// for each dependency, recurse using this function
	for _, dep := range meta.Dependencies() {
		err = fetchLibraryWithDependencies(ctx, processed, dep, result)
		if err != nil {
			return fmt.Errorf("FetchLibraryWithDependencies: error fetching dependencies for library %s: %w", lib.String(), err)
		}
	}
	// add the current library reference to the list
	*result = append(*result, lib)
	processed[lib.String()] = true
	return nil
}