GetModFile returns an AST of the given directory's go.mod file and returns err if file is not found.
(dir string)
| 11 | // GetModFile returns an AST of the given directory's go.mod file |
| 12 | // and returns err if file is not found. |
| 13 | func GetModFile(dir string) (*modfile.File, error) { |
| 14 | bts, err := os.ReadFile(filepath.Join(dir, "go.mod")) |
| 15 | if err != nil { |
| 16 | return nil, fmt.Errorf("could not open go.mod file: %w", err) |
| 17 | } |
| 18 | f, err := modfile.Parse(filepath.Join(dir, "go.mod"), bts, nil) |
| 19 | if err != nil { |
| 20 | return nil, fmt.Errorf("could not parse go.mod file: %w", err) |
| 21 | } |
| 22 | return f, nil |
| 23 | } |
no outgoing calls
searching dependent graphs…