Skip to content

Commit a067bb1

Browse files
committed
docs: ✏️ add goreportcard badge
1 parent efdf787 commit a067bb1

File tree

4 files changed

+23
-20
lines changed

4 files changed

+23
-20
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Little cli utility for lazy guy😉 ~ Transforming protobuf idl to thrift, and v
33

44
[![YYCoder](https://circleci.com/gh/YYCoder/protobuf-thrift.svg?style=svg)](https://app.circleci.com/pipelines/github/YYCoder/protobuf-thrift)
55
[![GoDoc](https://pkg.go.dev/badge/github.com/YYCoder/protobuf-thrift)](https://pkg.go.dev/github.com/YYCoder/protobuf-thrift)
6+
[![goreportcard](https://goreportcard.com/badge/github.com/yycoder/protobuf-thrift)](https://goreportcard.com/report/github.com/yycoder/protobuf-thrift)
67

78
> [IDL](https://en.wikipedia.org/wiki/IDL)(Interface description language), which is a descriptive language used to define data types and interfaces in a way that is independent of the programming language or operating system/processor platform.
89
@@ -21,13 +22,13 @@ For Gophers, you can just `go install github.com/YYCoder/protobuf-thrift` it you
2122
Basic thrift file to protobuf file transform:
2223

2324
```
24-
protobuf-thrift -t thrift2proto -i ./path/to/idl.thrift -o ./idl.proto`
25+
protobuf-thrift -t thrift2proto -i ./path/to/idl.thrift -o ./idl.proto
2526
```
2627

2728
Basic protobuf file to thrift file transform:
2829

2930
```
30-
protobuf-thrift -t proto2thrift -i ./path/to/idl.thrift -o ./test.proto`
31+
protobuf-thrift -t proto2thrift -i ./path/to/idl.thrift -o ./test.proto
3132
```
3233

3334
### Interactive Usage
@@ -46,7 +47,7 @@ Under some circumstances, you may want to transform a whole idl repo to another
4647
This option is off by default, so you have to specify it explicitly.
4748

4849
```
49-
protobuf-thrift -t thrift2proto -i ./path/to/idl.thrift -o ./idl.proto -r 1`
50+
protobuf-thrift -t thrift2proto -i ./path/to/idl.thrift -o ./idl.proto -r 1
5051
```
5152

5253

docs/cn.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# protobuf-thrift
22
为懒人准备的 protobuf 与 thrift 互转的小工具😉。
33

4+
[![YYCoder](https://circleci.com/gh/YYCoder/protobuf-thrift.svg?style=svg)](https://app.circleci.com/pipelines/github/YYCoder/protobuf-thrift)
5+
[![GoDoc](https://pkg.go.dev/badge/github.com/YYCoder/protobuf-thrift)](https://pkg.go.dev/github.com/YYCoder/protobuf-thrift)
6+
[![goreportcard](https://goreportcard.com/badge/github.com/yycoder/protobuf-thrift)](https://goreportcard.com/report/github.com/yycoder/protobuf-thrift)
7+
48
> [IDL](https://en.wikipedia.org/wiki/IDL)(Interface description language)。是指一种用于定义数据类型以及接口的描述性语言,与编程语言以及平台无关,常用在微服务架构中。
59
610
## 安装
@@ -14,13 +18,13 @@
1418
将 thrift 文件转成 protobuf 文件:
1519

1620
```
17-
protobuf-thrift -t thrift2proto -i ./path/to/idl.thrift -o ./idl.proto`
21+
protobuf-thrift -t thrift2proto -i ./path/to/idl.thrift -o ./idl.proto
1822
```
1923

2024
将 protobuf 文件转成 thrift 文件:
2125

2226
```
23-
protobuf-thrift -t proto2thrift -i ./path/to/idl.thrift -o ./test.proto`
27+
protobuf-thrift -t proto2thrift -i ./path/to/idl.thrift -o ./test.proto
2428
```
2529

2630
### 交互式用法
@@ -38,7 +42,7 @@ protobuf-thrift -t proto2thrift -i ./path/to/idl.thrift -o ./test.proto`
3842

3943

4044
```
41-
protobuf-thrift -t thrift2proto -i ./path/to/idl.thrift -o ./idl.proto -r 1`
45+
protobuf-thrift -t thrift2proto -i ./path/to/idl.thrift -o ./idl.proto -r 1
4246
```
4347

4448

proto-2-thrift-gen.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,9 @@ func (g *thriftGenerator) Parse() (newFiles []FileInfo, err error) {
132132
case *proto.Option:
133133
case *proto.Comment:
134134
ele := e.(*proto.Comment)
135-
logger.Infof("proto.Comment comment %+v", ele)
136135
g.handleComment(ele, false, 0)
137136
default:
138-
logger.Infof("other: %+v\n", e)
137+
// logger.Infof("other: %+v\n", e)
139138
}
140139
}
141140

thrift-2-proto-gen.go

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,18 @@ import (
1010
"strconv"
1111
"strings"
1212

13-
"github.com/emicklei/proto"
14-
goThrift "github.com/samuel/go-thrift/parser"
15-
1613
"github.com/YYCoder/protobuf-thrift/utils"
1714
"github.com/YYCoder/protobuf-thrift/utils/logger"
15+
"github.com/YYCoder/thrifter"
16+
"github.com/emicklei/proto"
1817
)
1918

2019
type protoGenerator struct {
2120
conf *protoGeneratorConfig
22-
def *goThrift.Thrift
21+
def *thrifter.Thrift
2322
file *os.File
2423
protoContent bytes.Buffer
25-
protoAST *proto.Proto
24+
// protoAST *proto.Proto
2625
}
2726

2827
type protoGeneratorConfig struct {
@@ -42,22 +41,22 @@ type protoGeneratorConfig struct {
4241
}
4342

4443
func NewProtoGenerator(conf *protoGeneratorConfig) (res SubGenerator, err error) {
45-
var parser *goThrift.Parser
44+
var parser *thrifter.Parser
4645
var file *os.File
47-
var definition *goThrift.Thrift
46+
var definition *thrifter.Thrift
4847
if conf.taskType == TASK_FILE_THRIFT2PROTO {
4948
file, err = os.Open(conf.filePath)
5049
if err != nil {
5150
return nil, err
5251
}
5352
defer file.Close()
54-
parser = &goThrift.Parser{Filesystem: nil}
55-
definition, err = parser.Parse(file)
53+
parser = thrifter.NewParser(file, false)
54+
definition, err = parser.Parse(file.Name())
5655

5756
} else if conf.taskType == TASK_CONTENT_THRIFT2PROTO {
5857
rd := strings.NewReader(conf.rawContent)
59-
parser = &goThrift.Parser{Filesystem: nil}
60-
definition, err = parser.Parse(rd)
58+
parser = thrifter.NewParser(rd, false)
59+
definition, err = parser.Parse("INPUT")
6160
}
6261

6362
if err != nil {
@@ -81,7 +80,7 @@ func (g *protoGenerator) FilePath() (res string) {
8180
return
8281
}
8382

84-
// generate protoAST from thrift ast, return absolute file paths included by current file
83+
// parse thrift ast, return absolute file paths included by current file
8584
func (g *protoGenerator) Parse() (newFiles []FileInfo, err error) {
8685
g.protoAST = &proto.Proto{}
8786

0 commit comments

Comments
 (0)