Setting: ignoreUnexported
ignoreUnexported [yes,no]
is a boolean setting and can be defined as CLI argument, conversion comment or method comment. This setting is inheritable.
If a struct has multiple unexported fields that should be ignored, then you can enable ignoreUnexported
, to ignore these.
DANGER
Using this setting is not recommended, because this can easily lead to unwanted behavior. When a struct is having unexported fields, you most likely have to call a custom constructor method to correctly instantiate this type.
go
package example
// goverter:converter
type Converter interface {
// goverter:ignoreUnexported
Convert(source Input) Output
}
type Input struct {
Name string
}
type Output struct {
Name string
// goverter will skip this field
age int
street string
}
go
// Code generated by github.com/jmattheis/goverter, DO NOT EDIT.
//go:build !goverter
package generated
import ignoreunexported "github.com/jmattheis/goverter/example/ignore-unexported"
type ConverterImpl struct{}
func (c *ConverterImpl) Convert(source ignoreunexported.Input) ignoreunexported.Output {
var exampleOutput ignoreunexported.Output
exampleOutput.Name = source.Name
return exampleOutput
}