Skip to content

Commit 36c5e4d

Browse files
authored
Merge pull request #3 from lim-yoona/docs/update_README
update README: Add explain for safetcpack
2 parents 1c3667a + 99af039 commit 36c5e4d

File tree

4 files changed

+63
-1
lines changed

4 files changed

+63
-1
lines changed

README-CN.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616

1717
[tcpack](https://pkg.go.dev/github.com/lim-yoona/tcpack) 就是为了解决这个问题,将请求数据封装成消息,发送时打包,接收时解包。
1818

19-
*注意: 在同一个连接上使用打包器并发读写消息是不安全的,不要去这样做,会带来不可预知的后果!*
19+
*注意: 在同一个连接上使用打包器并发读写消息是不安全的,不要去这样做,会带来不可预知的后果!*
20+
21+
如果你想要使用在同一个TCP连接上的多个打包器并发地收发消息,请使用 [safetcpack](https://github.com/lim-yoona/tcpack/tree/main/safe/README-CN.md)
2022

2123
## tcpack中有什么?
2224

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ As we all know, TCP is a transport layer protocol oriented to byte streams. Its
1919

2020
*notice: It is unsafe to use a packer to read and write messages concurrently on the same connection. Do not do this, as it will have unpredictable consequences!*
2121

22+
If you want to use multiple packagers based on the same TCP connection to send and receive messages concurrently, please use [safetcpack](https://github.com/lim-yoona/tcpack/tree/main/safe/README.md).
23+
2224
## What's in the box?
2325

2426
This library provides a packager which support Pack and Unpack.

safe/README-CN.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# safetcpack
2+
简体中文 | [English](README.md)
3+
4+
safetcpack提供了tcpack的线程安全的版本。
5+
6+
## 与tcpack的区别
7+
与tcpack不同的是,使用safetcpack,你可以为一个TCP连接构造多个打包器,并在多个goroutine中并发地使用他们。
8+
9+
*注意:在同一个TCP连接上并发地使用多个打包器收发消息会导致发送和收到的消息顺序不确定,如果您想保证消息的按序发送和接收,请使用tcpack并且避免并发。*
10+
11+
## 安装指南
12+
13+
1. 为安装 safetcpack 包, 首先你需要安装 [Go](https://go.dev/doc/install) , 然后你可以使用下面的命令将 `safetcpack` 作为你Go程序的依赖。
14+
15+
```sh
16+
go get -u github.com/lim-yoona/tcpack
17+
```
18+
19+
2. 在代码中导入 safetcpack :
20+
21+
```go
22+
import safetcpack "github.com/lim-yoona/tcpack/safe"
23+
```
24+
25+
## 使用
26+
safetcpack 的使用方法与 tcpack 一致。
27+
28+
## 示例
29+
Here are some [Examples](https://github.com/lim-yoona/tcpack/blob/main/example/concurrencyPack.go).

safe/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# safetcpack
2+
English | [简体中文](README-CN.md)
3+
4+
safetcpack provides a thread-safe version of tcpack.
5+
6+
## Difference from tcpack
7+
Unlike tcpack, with safetcpack, you can construct multiple packers for a TCP connection and use them concurrently in multiple goroutines.
8+
9+
*Notice: Using of multiple packagers based on the same TCP connection to send and receive messages concurrently can result in uncertain order of messages sent and received. If you want to ensure that messages are sent and received in order, please use tcpack and avoid concurrency.*
10+
11+
## Installation Guidelines
12+
1. To install the safetcpack package, you first need to have [Go](https://go.dev/doc/install) installed, then you can use the command below to add `safetcpack` as a dependency in your Go program.
13+
14+
```sh
15+
go get -u github.com/lim-yoona/tcpack
16+
```
17+
18+
2. Import it in your code:
19+
20+
```go
21+
import safetcpack "github.com/lim-yoona/tcpack/safe"
22+
```
23+
24+
## Usage
25+
The usage of safetcpack is consistent with that of tcpack.
26+
27+
## Examples
28+
29+
Here are some [Examples](https://github.com/lim-yoona/tcpack/blob/main/example/concurrencyPack.go).

0 commit comments

Comments
 (0)