Skip to content

Latest commit

 

History

History
41 lines (32 loc) · 904 Bytes

README.md

File metadata and controls

41 lines (32 loc) · 904 Bytes

Gengo

GoDoc Widget codecov Go Report Card

package customgen

import (
	"go/ast"
	"go/types"

	"github.com/octohelm/gengo/pkg/gengo"
)

func init() {
	gengo.Register(&customGen{})
}

type customGen struct {
}

func (*customGen) Name() string {
	return "custom"
}

func (g *customGen) GenerateType(c gengo.Context, named *types.Named) error {
	if !ast.IsExported(named.Obj().Name()) {
		// skip type 
		return gengo.ErrSkip
	}

	if whenSomeThing() {
		// end generate but ignore error
		return gengo.ErrIgnore
	}
	// do generate
	return nil
}