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

feat: support new generate flag generate_json_str #120

Merged
merged 8 commits into from
Dec 1, 2023

Conversation

xiekeyi98
Copy link
Contributor

Description

As #119 said, add new flag generate_json_string_method to generate JSON marshal string in String() Method.

Motivation and Context

It is useful when we need get the struct JSON string in some situation.

Related Issue

closes #119

@xiekeyi98 xiekeyi98 requested review from a team as code owners August 25, 2023 09:26
@HeyJavaBean HeyJavaBean changed the title 🎸 (feat): Go_Options:Support new generate flag generate_json_str feat: Go_Options:Support new generate flag generate_json_str Aug 31, 2023
@HeyJavaBean HeyJavaBean changed the title feat: Go_Options:Support new generate flag generate_json_str feat: support new generate flag generate_json_str Aug 31, 2023
@HeyJavaBean
Copy link
Member

ok,看起来没问题。我再看下怎么配合类似 Hertz.UseJSONLib( easyJson ) 的方式来做

@xiekeyi98
Copy link
Contributor Author

ok,看起来没问题。我再看下怎么配合类似 Hertz.UseJSONLib( easyJson ) 的方式来做

感觉要看下这个用法的人多不多。
多的话下一步:

  1. 抽一个新的文件用来处理 JSON;
  2. 生成出来的还是 std 的 JSON 文件,但开一个类似于 hertz 的口给用户传入自己的 Marshal 方法。
  3. 用户可以在 {Service_Name}.UseJSONLib() 来替换生成代码对应的 package 的 JSON 代码。

说来这个需求的人多么?

@HeyJavaBean
Copy link
Member

不算多,但之前也有个业务线的同学提过。「下一步」可以先做出来把接口留好

@xiekeyi98
Copy link
Contributor Author

xiekeyi98 commented Aug 31, 2023

我来改下,这个口子开出来吧。

generator/golang/templates/file.go Outdated Show resolved Hide resolved
generator/golang/option.go Outdated Show resolved Hide resolved
@xiekeyi98
Copy link
Contributor Author

@HeyJavaBean 大概改了下,PTAL~

另外 silm 的生成参数是什么样子的?

go build && ./thriftgo -o . -g go:json_stringer=true  ./test/golang/cases_and_options/thrifttest/a.thrift

好像这个不行⬇️
go build && ./thriftgo -silm -o . -g go:json_stringer=true  ./test/golang/cases_and_options/thrifttest/a.thrift

@xiekeyi98 xiekeyi98 force-pushed the dev/keyi_string_json branch from f9f7ca2 to 276afde Compare November 29, 2023 09:05
@HeyJavaBean HeyJavaBean merged commit b5ef551 into cloudwego:main Dec 1, 2023
2 of 3 checks passed
@xiekeyi98 xiekeyi98 deleted the dev/keyi_string_json branch December 1, 2023 03:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Proposal: Add a new flag to generate another type String()
2 participants