Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"struct:error:name" and "struct:field:name" not work together #2596

Merged
merged 1 commit into from Jun 16, 2020

Conversation

mrsndmn
Copy link
Contributor

@mrsndmn mrsndmn commented Jun 16, 2020

Following code

var Result = ResultType("application/vnd.goa.error", func() {
    Attribute("error", String, func() {
        Meta("struct:error:name")
        Meta("struct:field:name", "ErrorCode")
    })
    Required("error")
})

Generated code:

type GoaError struct {
    ErrorCode string
}

// Error returns an error description.
func (e *GoaError) Error() string {
    return ""
}

// ErrorName returns "GoaError".
func (e *GoaError) ErrorName() string {
    return e.Error
}

This code won't be compiled:

cannot use e.Error (type func() string) as type string in return argument

See full example of DSL and generated code in tests below.

@raphael
Copy link
Member

raphael commented Jun 16, 2020

Good catch! thank you. Can you please back-port to the v2 branch as well? (simply cherry-pick the merge commit).

@raphael raphael merged commit b464bda into goadesign:v3 Jun 16, 2020
mrsndmn added a commit to mrsndmn/goa that referenced this pull request Jun 16, 2020
raphael pushed a commit that referenced this pull request Jun 16, 2020
…2596) (#2597)

Co-authored-by: Dmitry Tarasov <d.tarasov@corp.mail.ru>

Co-authored-by: Dmitry Tarasov <d.tarasov@corp.mail.ru>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants