MCPcopy Create free account
hub / github.com/bufbuild/buf / getModuleDeps

Function getModuleDeps

private/bufpkg/bufmodule/module_dep.go:80–113  ·  view source on GitHub ↗

getModuleDeps gets the actual dependencies for the Module.

(
	ctx context.Context,
	module Module,
)

Source from the content-addressed store, hash-verified

78
79// getModuleDeps gets the actual dependencies for the Module.
80func getModuleDeps(
81 ctx context.Context,
82 module Module,
83) ([]ModuleDep, error) {
84 depOpaqueIDToModuleDep := make(map[string]ModuleDep)
85 protoFileTracker := newProtoFileTracker()
86 if err := getModuleDepsRec(
87 ctx,
88 module,
89 make(map[string]string),
90 make(map[string]struct{}),
91 nil,
92 depOpaqueIDToModuleDep,
93 protoFileTracker,
94 true,
95 ); err != nil {
96 return nil, err
97 }
98 if err := protoFileTracker.validate(); err != nil {
99 return nil, err
100 }
101 moduleDeps := make([]ModuleDep, 0, len(depOpaqueIDToModuleDep))
102 for _, moduleDep := range depOpaqueIDToModuleDep {
103 moduleDeps = append(moduleDeps, moduleDep)
104 }
105 // Sorting by at least Opaque ID to get a consistent return order for a given call.
106 sort.Slice(
107 moduleDeps,
108 func(i int, j int) bool {
109 return moduleDeps[i].OpaqueID() < moduleDeps[j].OpaqueID()
110 },
111 )
112 return moduleDeps, nil
113}
114
115func getModuleDepsRec(
116 ctx context.Context,

Callers 1

Calls 4

newProtoFileTrackerFunction · 0.85
getModuleDepsRecFunction · 0.85
OpaqueIDMethod · 0.65
validateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…