Skip to content

Commit

Permalink
gopbuild: fix loader gop
Browse files Browse the repository at this point in the history
  • Loading branch information
visualfc committed Mar 26, 2023
1 parent 557bbeb commit c4c4baf
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion gopbuild/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ func (p *Package) ToAst() *goast.File {
type Context struct {
ctx *igop.Context
fset *token.FileSet
gop igop.Loader
}

func IsClass(ext string) (isProj bool, ok bool) {
Expand All @@ -144,7 +145,7 @@ func IsClass(ext string) (isProj bool, ok bool) {
}

func NewContext(ctx *igop.Context) *Context {
return &Context{ctx: ctx, fset: token.NewFileSet()}
return &Context{ctx: ctx, fset: token.NewFileSet(), gop: igop.NewTypesLoader(ctx, 0)}
}

func isGopPackage(path string) bool {
Expand All @@ -157,6 +158,9 @@ func isGopPackage(path string) bool {
}

func (c *Context) Import(path string) (*types.Package, error) {
if isGopPackage(path) {
return c.gop.Import(path)
}
return c.ctx.Loader.Import(path)
}

Expand Down

0 comments on commit c4c4baf

Please sign in to comment.