type ParsedModule … // ParseMod parses a go.mod file, using a cache. It may return partial results and an error. func (s *Snapshot) ParseMod(ctx context.Context, fh file.Handle) (*ParsedModule, error) { … } // parseModImpl parses the go.mod file whose name and contents are in fh. // It may return partial results and an error. func parseModImpl(ctx context.Context, fh file.Handle) (*ParsedModule, error) { … } type ParsedWorkFile … // ParseWork parses a go.work file, using a cache. It may return partial results and an error. // TODO(adonovan): move to new work.go file. func (s *Snapshot) ParseWork(ctx context.Context, fh file.Handle) (*ParsedWorkFile, error) { … } // parseWorkImpl parses a go.work file. It may return partial results and an error. func parseWorkImpl(ctx context.Context, fh file.Handle) (*ParsedWorkFile, error) { … } // ModWhy returns the "go mod why" result for each module named in a // require statement in the go.mod file. // TODO(adonovan): move to new mod_why.go file. func (s *Snapshot) ModWhy(ctx context.Context, fh file.Handle) (map[string]string, error) { … } // modWhyImpl returns the result of "go mod why -m" on the specified go.mod file. func modWhyImpl(ctx context.Context, snapshot *Snapshot, fh file.Handle) (map[string]string, error) { … } // extractGoCommandErrors tries to parse errors that come from the go command // and shape them into go.mod diagnostics. // TODO: rename this to 'load errors' func (s *Snapshot) extractGoCommandErrors(ctx context.Context, goCmdError error) []*Diagnostic { … } var moduleVersionInErrorRe … // matchErrorToModule matches a go command error message to a go.mod file. // Some examples: // // [email protected]: reading example.com/@v/v1.2.2.mod: no such file or directory // go: github.com/cockroachdb/apd/[email protected]: reading github.com/cockroachdb/apd/go.mod at revision v2.0.72: unknown revision v2.0.72 // go: [email protected] requires\n\[email protected]: parsing go.mod:\n\tmodule declares its path as: bob.org\n\tbut was required as: random.org // // It returns the location of a reference to the one of the modules and true // if one exists. If none is found it returns a fallback location and false. func (s *Snapshot) matchErrorToModule(pm *ParsedModule, goCmdError string) (protocol.Location, bool, error) { … } // goCommandDiagnostic creates a diagnostic for a given go command error. func (s *Snapshot) goCommandDiagnostic(pm *ParsedModule, loc protocol.Location, goCmdError string) (*Diagnostic, error) { … } func findModuleReference(mf *modfile.File, ver module.Version) *modfile.Line { … }