MCPcopy Create free account
hub / github.com/docker/secrets-engine / getDirectProjectDependencies

Function getDirectProjectDependencies

x/release/command.go:215–236  ·  view source on GitHub ↗
(mod string)

Source from the content-addressed store, hash-verified

213}
214
215func getDirectProjectDependencies(mod string) ([]string, error) {
216 modPath := filepath.Join(mod, "go.mod")
217 data, err := os.ReadFile(filepath.Join(mod, "go.mod"))
218 if err != nil {
219 return nil, err
220 }
221 f, err := modfile.Parse(modPath, data, nil)
222 if err != nil {
223 return nil, err
224 }
225 var deps []string
226 base, err := getModBase(f.Module.Mod.Path)
227 if err != nil {
228 return nil, err
229 }
230 for _, require := range f.Require {
231 if strings.HasPrefix(require.Mod.Path, base) {
232 deps = append(deps, strings.TrimPrefix(require.Mod.Path, base+"/"))
233 }
234 }
235 return deps, nil
236}
237
238func getModBase(modPath string) (string, error) {
239 parts := strings.SplitN(modPath, "/", 4)

Callers 1

newRepoDataFunction · 0.85

Calls 1

getModBaseFunction · 0.85

Tested by

no test coverage detected