10000 fix AdditionalArgs by qwenode · Pull Request #28 · reedom/convergen · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix AdditionalArgs #28

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

Merged

Conversation

qwenode
Copy link
Contributor
@qwenode qwenode commented Apr 14, 2025

try:

package data

type UserA struct {
	Username string `json:"username"`
}
type UserB struct {
	Username string  `json:"username"`
	Age      int     `json:"age"`
	User     UserA   `json:"user"`
	Slice    []UserA `json:"slice"`
}
type Gen interface {
	// :map $2 Age
	// :map $3 User
	// :skip Slice
	// :typecast
	UserA_UserB(data.UserA, int, data.UserA) data.UserB
	// :map $2 Age
	// :map $3 Slice
	// :map $4 User
	// :typecast
	UserA_UserB2(data.UserA, int, []data.UserA, data.UserA) data.UserB
}

will generate:

func UserA_UserB(src data.UserA, arg0 int, arg1 data.UserA) (dst data.UserB) {
	dst.Username = src.Username
	dst.Age = arg0
	dst.User = arg1
	// skip: dst.Slice

	return
}

func UserA_UserB2(src data.UserA, arg0 int, arg1 []github.com/reedom/convergen/data/data.UserA, arg2 data.UserA) (dst data.UserB) {
	dst.Username = src.Username
	dst.Age = arg0
	dst.User = arg2
	dst.Slice = arg1

	return
}

Copy link
Owner
@reedom reedom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for your contribution — really appreciate the patch!

I’ve left one small suggestion for improvement. Also, it would be great if you could add a test for this change when you have a chance. That would help ensure everything keeps working as expected.

Thanks again!

qwenode and others added 2 commits April 22, 2025 14:21
thx

Co-authored-by: HANAI Tohru <tohru@reedom.com>
@reedom reedom mentioned this pull request Apr 23, 2025
@reedom reedom merged commit d3280f5 into reedom:main Apr 23, 2025
@reedom
Copy link
Owner
reedom commented Apr 23, 2025

Thank you, merged. 😄

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.

2 participants
0