MCPcopy Create free account
hub / github.com/a-h/rest / Get

Function Get

getcomments/parser/parser.go:12–31  ·  view source on GitHub ↗
(packageName string)

Source from the content-addressed store, hash-verified

10)
11
12func Get(packageName string) (m map[string]string, err error) {
13 config := &packages.Config{
14 Mode: packages.NeedTypes | packages.NeedTypesInfo | packages.NeedSyntax,
15 Tests: true,
16 }
17 pkgs, err := packages.Load(config, packageName)
18 if err != nil {
19 err = fmt.Errorf("error loading package %s: %w", packageName, err)
20 return
21 }
22
23 // Add the comments to the definitions.
24 m = make(map[string]string)
25 for _, pkg := range pkgs {
26 for _, file := range pkg.Syntax {
27 processFile(packageName, pkg, file, m)
28 }
29 }
30 return
31}
32
33func processFile(packageName string, pkg *packages.Package, file *ast.File, m map[string]string) {
34 var lastComment string

Callers 4

getCommentsForPackageMethod · 0.92
mainFunction · 0.92
TestGetFunction · 0.92
mainFunction · 0.92

Calls 1

processFileFunction · 0.85

Tested by 1

TestGetFunction · 0.74