Skip to content

Setting: skipCopySameType ‚Äč

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

Goverter deep copies instances when converting the source to the target type. With goverter:skipCopySameType you instruct Goverter to skip copying instances when the source and target type is the same.

go
package example

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

type Input struct {
	Name       *string
	ItemCounts map[string]int
}

type Output struct {
	Name       *string
	ItemCounts map[string]int
}
go
// Code generated by github.com/jmattheis/goverter, DO NOT EDIT.
//go:build !goverter

package generated

import skipcopysametype "github.com/jmattheis/goverter/example/skip-copy-same-type"

type ConverterImpl struct{}

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