MCPcopy Index your code
hub / github.com/dgraph-io/dgraph / fixGoModIfNeeded

Function fixGoModIfNeeded

dgraphtest/image.go:340–363  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

338}
339
340func fixGoModIfNeeded() error {
341 repoModFilePath := filepath.Join(repoDir, "go.mod")
342 repoModFile, err := modfile.Parse(repoModFilePath, nil, nil)
343 if err != nil {
344 return errors.Wrapf(err, "error parsing mod file in repoDir [%v]", repoDir)
345 }
346
347 modFile, err := modfile.Parse("go.mod", nil, nil)
348 if err != nil {
349 return errors.Wrapf(err, "error while parsing go.mod file")
350 }
351
352 if len(modFile.Replace) == len(repoModFile.Replace) {
353 return nil
354 }
355
356 repoModFile.Replace = modFile.Replace
357 if data, err := repoModFile.Format(); err != nil {
358 return errors.Wrapf(err, "error while formatting mod file")
359 } else if err := os.WriteFile(repoModFilePath, data, 0644); err != nil {
360 return errors.Wrapf(err, "error while writing to go.mod file")
361 }
362 return nil
363}

Callers 1

buildDgraphBinaryFunction · 0.85

Calls 2

FormatMethod · 0.80
ParseMethod · 0.65

Tested by

no test coverage detected