Skip to content

Commit

Permalink
add README
Browse files Browse the repository at this point in the history
  • Loading branch information
yc90s committed Feb 20, 2024
1 parent 80aa5ce commit 1fd460e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
4 changes: 2 additions & 2 deletions cmd/xrpc/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# xrpc 说明
English(README.md) | 中文
[English](README_en.md) | 中文

xrpc是用来自动生成rpc服务接口信息代码的工具

Expand All @@ -9,7 +9,7 @@ xrpc是用来自动生成rpc服务接口信息代码的工具
go install github.com/yc90s/xrpc/cmd/xrpc@latest
```

2. 编写接口文件hello.service, 定义一个服务`HelloService`, 它提供两个接口
2. 编写一个接口文件`hello.service`如下, 它定义了一个服务`HelloService`, 包含两个接口
```
package main
Expand Down
14 changes: 7 additions & 7 deletions cmd/xrpc/README_en.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# xrpc demo
English | 中文(README_cn.md)
English | [中文](README.md)

xrpc is a tool used to automatically generate RPC service interface information codes.

## Getting Started
1. download xrpc
1. Download xrpc
```git
go install github.com/yc90s/xrpc/cmd/xrpc@latest
```

2. write the interface file hello.service and define a service called HelloService, which provides two interfaces
2. Write the interface file `hello.service` as follows, which defines a service `HelloService` that includes two interfaces
```
package main
Expand All @@ -19,7 +19,7 @@ service HelloService {
}
```

3. Generate code. Execute the following command to generate a hello. service. go file in the current directory, which defines the rpc interface information of the 'HelloService' service
3. Generate code. Execute the following command to generate a hello. service. go file in the current directory, which defines the rpc interface information of the `HelloService` service
```
xrpc -out ./ hello.service
```
Expand All @@ -30,20 +30,20 @@ xrpc -out ./ hello.service
Maximizing the closeness of interface files to Golang's native syntax.

1. Define package name
Each service needs to start with 'package', followed by the module's package name, which supports numbers, letters, and underscores.
Each service needs to start with `package`, followed by the module's package name, which supports numbers, letters, and underscores.
```
package main
```

2. import package
You can use the 'import' keyword to import other dependent packages, and each 'import' can only import one package.
You can use the `import` keyword to import other dependent packages, and each `import` can only import one package.
```
import "github.com/yc90s/xrpc/examples/protobuf/pb"
import "fmt"
```

3. Define Services
An interface file can define multiple services, with the keyword 'service' indicating the definition of a service, followed by the service name.
An interface file can define multiple services, with the keyword `service` indicating the definition of a service, followed by the service name.
```
service HelloService {
Expand Down
4 changes: 3 additions & 1 deletion cmd/xrpc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"html/template"
"os"
"path/filepath"

"github.com/yc90s/xrpc"
)

const tmplService = `// Code generated by xrpc. DO NOT EDIT.
Expand Down Expand Up @@ -124,7 +126,7 @@ func main() {
flag.Parse()

if version {
fmt.Println("xrpc v1.0.3")
fmt.Println(xrpc.Version)
return
}

Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package xrpc

const Version = "v1.0.3"
const Version = "v1.0.4"

0 comments on commit 1fd460e

Please sign in to comment.