Skip to content

Commit

Permalink
fix: interface should supported gen too
Browse files Browse the repository at this point in the history
  • Loading branch information
morlay committed Oct 8, 2024
1 parent 4bc8a41 commit cafe221
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
4 changes: 4 additions & 0 deletions devpkg/deepcopygen/deepcopy.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ func (g *deepcopyGen) generateType(c gengo.Context, named *types.Named) error {

g.processed[named] = true

if _, ok := named.Obj().Type().Underlying().(*types.Interface); ok {
return gengo.ErrSkip
}

tags, _ := c.Doc(named.Obj())
if !gengo.IsGeneratorEnabled(g, tags) {
return nil
Expand Down
4 changes: 4 additions & 0 deletions devpkg/runtimedocgen/runtimedoc.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ func (*runtimedocGen) Name() string {
}

func (g *runtimedocGen) GenerateType(c gengo.Context, named *types.Named) error {
if _, ok := named.Obj().Type().Underlying().(*types.Interface); ok {
return gengo.ErrSkip
}

if !ast.IsExported(named.Obj().Name()) {
return gengo.ErrSkip
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/octohelm/gengo

go 1.23.1
go 1.23.2

require (
github.com/go-courier/logr v0.3.0
Expand Down
5 changes: 0 additions & 5 deletions pkg/gengo/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,6 @@ func (c *context) doGenerate(ctx corecontext.Context, g Generator) error {
for _, n := range names {
tpe := pkgTypes[n].Type()

// skip type XXX any
if _, ok := tpe.Underlying().(*types.Interface); ok {
continue
}

if named, ok := tpe.(*types.Named); ok {
// skip alias other pkg type XXX = XXX2
if named.Obj().Pkg() != c.pkg.Pkg() {
Expand Down

0 comments on commit cafe221

Please sign in to comment.