Skip to content

Setting: ignore ‚Äč

ignore FIELD... can be defined as method comment.

If certain fields shouldn't be converted, are missing on the source struct, or aren't needed, then you can use ignore to ignore these fields.

ignore accepts multiple fields separated by spaces. If you want a more global approach see ignoreMissing or ignoreUnexported

go
package example

// goverter:converter
type Converter interface {
	// goverter:ignore Age
	Convert(source Input) Output
}

type Input struct {
	Name string
}
type Output struct {
	Name string
	Age  int
}
go
// Code generated by github.com/jmattheis/goverter, DO NOT EDIT.
//go:build !goverter

package generated

import ignore "github.com/jmattheis/goverter/example/ignore"

type ConverterImpl struct{}

func (c *ConverterImpl) Convert(source ignore.Input) ignore.Output {
	var exampleOutput ignore.Output
	exampleOutput.Name = source.Name
	return exampleOutput
}