Skip to content

Setting: ignoreMissing ‚Äč

ignoreMissing [yes,no] is a boolean setting and can be defined as CLI argument, converter comment or method comment. This setting is inheritable.

If the source struct has multiple missing exported fields that should be ignored, then you can enable ignoreMissing, to ignore these.

DANGER

Using this setting is not recommended, because this can easily lead to unwanted behavior when e.g. renaming fields on a struct and forgetting to change the goverter converter accordingly.

go
package example

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

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

package generated

import ignoremissing "github.com/jmattheis/goverter/example/ignore-missing"

type ConverterImpl struct{}

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