gg icon indicating copy to clipboard operation
gg copied to clipboard

support no-name function result

Open yujiachen-y opened this issue 2 years ago • 4 comments

Hi, here is the request for supporting no-name function result. Sometimes setup result names for a tiny function is unnecessary. E.g. 👇🏼

func GetName() (ignoreTheName string) {
        return name
}

yujiachen-y avatar Jun 18 '23 04:06 yujiachen-y

Thank you for the suggestion. However, I haven't been writing in Golang for some time now. Would you be willing to submit a pull request for this?

Xuanwo avatar Jun 18 '23 04:06 Xuanwo

Thank you for the suggestion. However, I haven't been writing in Golang for some time now. Would you be willing to submit a pull request for this?

Sure I'm willing to support the new feature. However I need to be familiar with the code before I can change it 😂. Now using fmt.Fprintf to directly produce those tiny functions is still a good alternative for me. Maybe next time I can help to build the feature lol

yujiachen-y avatar Jun 18 '23 04:06 yujiachen-y

I just found @Xuanwo your code already support the feature! 😂I've added 4 test cases in #15 .

BTW, I was plan to use gg to generate code in my project https://github.com/yujiachen-y/goaccessor . However I found the generated code still need to be gofmt by myself 🤔, so I don't use gg for now.

yujiachen-y avatar Jun 23 '23 14:06 yujiachen-y

However I found the generated code still need to be gofmt by myself , so I don't use gg for now.

Yes, gg only output the correctly AST and the format should be done by users. Maybe we can add format support before writing.

Xuanwo avatar Jun 23 '23 14:06 Xuanwo