gonstructor icon indicating copy to clipboard operation
gonstructor copied to clipboard

It breaks code generation if the property name is the reserved word

Open moznion opened this issue 2 years ago • 0 comments

example:

//go:generate gonstructor --type=Foo --constructorTypes=allArgs
type Foo struct {
	Type string
}

It outputs like the following error when it consumes the above structure:

2021/07/26 23:44:37 [error] failed to generate code: [GOWRTR-13] code formatter raises error: command='gofmt -e', err='<standard input>:5:14: expected type, found 'type'
<standard input>:7:9: expected operand, found 'type'
<standard input>:7:9: missing ',' in composite literal
<standard input>:7:13: expected operand, found ','
<standard input>:10:2: expected ';', found 'EOF'
<standard input>:10:2: expected ';', found 'EOF'
<standard input>:10:2: expected '}', found 'EOF'
<standard input>:10:2: expected '}', found 'EOF'
<standard input>:10:2: missing ',' in composite literal
', msg='exit status 2'

This because type is a reserved word of golang.

moznion avatar Jul 26 '21 14:07 moznion