MCPcopy Index your code
hub / github.com/coder/guts / include

Method include

convert.go:156–181  ·  view source on GitHub ↗
(directory string, prefix string, reference bool)

Source from the content-addressed store, hash-verified

154}
155
156func (p *GoParser) include(directory string, prefix string, reference bool) error {
157 pkgs, err := packages.Load(p.config, directory)
158 if err != nil {
159 return fmt.Errorf("failed to parse directory %s: %w", directory, err)
160 }
161
162 for _, v := range pkgs {
163 if _, ok := p.Pkgs[v.PkgPath]; ok {
164 return fmt.Errorf("package %s already exists", v.PkgPath)
165 }
166 p.Pkgs[v.PkgPath] = v
167 p.Reference[v.PkgPath] = reference
168 p.Prefix[v.PkgPath] = prefix
169 if len(v.Errors) > 0 {
170 for _, e := range v.Errors {
171 slog.Error(
172 parsePackageError(e),
173 slog.String("error", e.Error()),
174 slog.String("pkg", v.PkgPath),
175 slog.String("directory", directory),
176 )
177 }
178 }
179 }
180 return nil
181}
182
183// ToTypescript translates the Go types into the intermediate typescript AST
184// The returned typescript object can be mutated before serializing.

Callers 3

IncludeGenerateMethod · 0.95
IncludeReferenceMethod · 0.95

Calls 2

parsePackageErrorFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected