Skip to content

Setting: struct

struct:comment COMMENT

struct:comment COMMENT can be defined as CLI argument or conversion comment.

struct:comment instructs goverter to add a comment line to the generated struct. It can be configured multiple times to add multiline comments. Prefix your COMMENT with // to force single line comment style.

go
package example

// goverter:converter
// goverter:struct:comment // MyConverterImpl
// goverter:struct:comment //
// goverter:struct:comment // More detailed
type MultipleSingleLine interface {
	Convert(Input) Output
}

// goverter:converter
// goverter:struct:comment single comment
type SingleComment interface {
	Convert(Input) Output
}

// goverter:converter
// goverter:struct:comment MyConverterImpl
// goverter:struct:comment
// goverter:struct:comment More detailed
type MultiLine interface {
	Convert(Input) Output
}

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

package generated

import structcomment "github.com/jmattheis/goverter/example/struct-comment"

/*
MyConverterImpl

More detailed
*/
type MultiLineImpl struct{}

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

// MyConverterImpl
//
// More detailed
type MultipleSingleLineImpl struct{}

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

// single comment
type SingleCommentImpl struct{}

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