Skip to content

Commit

Permalink
change package name from 'msgpack' to 'tcpack'
Browse files Browse the repository at this point in the history
  • Loading branch information
lim-yoona committed Oct 10, 2023
1 parent 2e160f0 commit 63dbc47
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 42 deletions.
40 changes: 20 additions & 20 deletions README-CN.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
# msgpack
# tcpack

[![Go Reference](https://pkg.go.dev/badge/github.com/lim-yoona/msgpack.svg)](https://pkg.go.dev/github.com/lim-yoona/msgpack)
![GitHub](https://img.shields.io/github/license/lim-yoona/msgpack)
[![Go Report](https://img.shields.io/badge/go%20report-A+-brightgreen.svg?style=flat)](https://goreportcard.com/report/github.com/lim-yoona/msgpack)
![GitHub release (with filter)](https://img.shields.io/github/v/release/lim-yoona/msgpack)
[![Go Reference](https://pkg.go.dev/badge/github.com/lim-yoona/tcpack.svg)](https://pkg.go.dev/github.com/lim-yoona/tcpack)
![GitHub](https://img.shields.io/github/license/lim-yoona/tcpack)
[![Go Report](https://img.shields.io/badge/go%20report-A+-brightgreen.svg?style=flat)](https://goreportcard.com/report/github.com/lim-yoona/tcpack)
![GitHub release (with filter)](https://img.shields.io/github/v/release/lim-yoona/tcpack)

[English](README.md) | 简体中文

[msgpack](https://pkg.go.dev/github.com/lim-yoona/msgpack) 是一个基于 TCP 的应用层协议,用于在 [go](https://go.dev/) 程序中打包和解包字节流。
[tcpack](https://pkg.go.dev/github.com/lim-yoona/tcpack) 是一个基于 TCP 的应用层协议,用于在 [go](https://go.dev/) 程序中打包和解包字节流。

## msgpack做了什么
## tcpack做了什么

众所周知,TCP 是面向字节流的传输层协议,其数据传输没有明确的边界,因此应用层读取的数据可能包含多个请求而导致无法处理业务。

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

## msgpack中有什么?
## tcpack中有什么?

msgpack 提供了一个支持 Pack 和 Unpack 的打包器。
`tcpack` 提供了一个支持 Pack 和 Unpack 的打包器。

## 安装指南

1. 为安装 msgpack 包, 首先你需要安装 [Go](https://go.dev/doc/install) , 然后你可以使用下面的命令将 `msgpack` 作为你Go程序的依赖。
1. 为安装 tcpack 包, 首先你需要安装 [Go](https://go.dev/doc/install) , 然后你可以使用下面的命令将 `tcpack` 作为你Go程序的依赖。

```sh
go get -u github.com/lim-yoona/msgpack
go get -u github.com/lim-yoona/tcpack
```

2.msgpack 导入到代码中:
2.tcpack 导入到代码中:

```go
import "github.com/lim-yoona/msgpack"
import "github.com/lim-yoona/tcpack"
```

## 使用

```go
package main

import "github.com/lim-yoona/msgpack"
import "github.com/lim-yoona/tcpack"

func main() {
// 创建一个打包器
mp := msgpack.NewMsgPack(8, tcpConn)
mp := tcpack.NewMsgPack(8, tcpConn)

// 打包一个消息
msg := msgpack.NewMessage(0, uint32(len([]byte(data))), []byte(data))
msg := tcpack.NewMessage(0, uint32(len([]byte(data))), []byte(data))
msgByte, err := mp.Pack(msg)
num, err := tcpConn.Write(msgByte)

Expand All @@ -63,7 +63,7 @@ type Person struct {
}

// 创建一个打包器
mp := msgpack.NewMsgPack(8, tcpConn)
mp := tcpack.NewMsgPack(8, tcpConn)

// data JSON Marshal
data := &Person{
Expand All @@ -73,7 +73,7 @@ data := &Person{
dataJSON, _ := json.Marshal(data)

// 打包一个消息
msgSend := msgpack.NewMessage(0, uint32(len(dataJSON)), dataJSON)
msgSend := tcpack.NewMessage(0, uint32(len(dataJSON)), dataJSON)
msgSendByte, _ := mpClient.Pack(msgSend)
num, err := tcpConn.Write(msgSendByte)

Expand All @@ -87,5 +87,5 @@ json.Unmarshal(msgRsv.GetMsgData(), &dataRsv)

## 示例

这有一些 [示例](https://github.com/lim-yoona/msgpack/tree/main/example)
这有一些 [示例](https://github.com/lim-yoona/tcpack/tree/main/example)

34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
# msgpack
# tcpack

[![Go Reference](https://pkg.go.dev/badge/github.com/lim-yoona/msgpack.svg)](https://pkg.go.dev/github.com/lim-yoona/msgpack)
![GitHub](https://img.shields.io/github/license/lim-yoona/msgpack)
[![Go Report](https://img.shields.io/badge/go%20report-A+-brightgreen.svg?style=flat)](https://goreportcard.com/report/github.com/lim-yoona/msgpack)
![GitHub release (with filter)](https://img.shields.io/github/v/release/lim-yoona/msgpack)
[![Go Reference](https://pkg.go.dev/badge/github.com/lim-yoona/tcpack.svg)](https://pkg.go.dev/github.com/lim-yoona/tcpack)
![GitHub](https://img.shields.io/github/license/lim-yoona/tcpack)
[![Go Report](https://img.shields.io/badge/go%20report-A+-brightgreen.svg?style=flat)](https://goreportcard.com/report/github.com/lim-yoona/tcpack)
![GitHub release (with filter)](https://img.shields.io/github/v/release/lim-yoona/tcpack)

English | [简体中文](README-CN.md)


[msgpack](https://pkg.go.dev/github.com/lim-yoona/msgpack) is an application protocol based on TCP to Pack and Unpack bytes stream in [go](https://go.dev/) (or 'golang' for search engine friendliness) program.
[tcpack](https://pkg.go.dev/github.com/lim-yoona/tcpack) is an application protocol based on TCP to Pack and Unpack bytes stream in [go](https://go.dev/) (or 'golang' for search engine friendliness) program.

## What dose msgpack do?
## What dose tcpack do?

As we all know, TCP is a transport layer protocol oriented to byte streams. Its data transmission has no clear boundaries, so the data read by the application layer may contain multiple requests and cannot be processed.

[msgpack](https://pkg.go.dev/github.com/lim-yoona/msgpack) is to solve this problem by encapsulating the request data into a message, packaging it when sending and unpacking it when receiving.
[tcpack](https://pkg.go.dev/github.com/lim-yoona/tcpack) is to solve this problem by encapsulating the request data into a message, packaging it when sending and unpacking it when receiving.

## What's in the box?

This library provides a packager which support Pack and Unpack.

## Installation Guidelines

1. To install the msgpack package, you first need to have [Go](https://go.dev/doc/install) installed, then you can use the command below to add `msgpack` as a dependency in your Go program.
1. To install the tcpack package, you first need to have [Go](https://go.dev/doc/install) installed, then you can use the command below to add `tcpack` as a dependency in your Go program.

```sh
go get -u github.com/lim-yoona/msgpack
go get -u github.com/lim-yoona/tcpack
```

2. Import it in your code:

```go
import "github.com/lim-yoona/msgpack"
import "github.com/lim-yoona/tcpack"
```

## Usage

```go
package main

import "github.com/lim-yoona/msgpack"
import "github.com/lim-yoona/tcpack"

func main() {
// Create a packager
mp := msgpack.NewMsgPack(8, tcpConn)
mp := tcpack.NewMsgPack(8, tcpConn)

// Pack a message
msg := msgpack.NewMessage(0, uint32(len([]byte(data))), []byte(data))
msg := tcpack.NewMessage(0, uint32(len([]byte(data))), []byte(data))
msgByte, err := mp.Pack(msg)
num, err := tcpConn.Write(msgByte)

Expand All @@ -64,7 +64,7 @@ type Person struct {
}

// Create a packager
mp := msgpack.NewMsgPack(8, tcpConn)
mp := tcpack.NewMsgPack(8, tcpConn)

// data JSON Marshal
data := &Person{
Expand All @@ -74,7 +74,7 @@ data := &Person{
dataJSON, _ := json.Marshal(data)

// Pack a message
msgSend := msgpack.NewMessage(0, uint32(len(dataJSON)), dataJSON)
msgSend := tcpack.NewMessage(0, uint32(len(dataJSON)), dataJSON)
msgSendByte, _ := mpClient.Pack(msgSend)
num, err := tcpConn.Write(msgSendByte)

Expand All @@ -88,5 +88,5 @@ json.Unmarshal(msgRsv.GetMsgData(), &dataRsv)

## Examples

Here are some [Examples](https://github.com/lim-yoona/msgpack/tree/main/example).
Here are some [Examples](https://github.com/lim-yoona/tcpack/tree/main/example).

7 changes: 5 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
module github.com/lim-yoona/msgpack
module github.com/lim-yoona/tcpack

go 1.20

require github.com/smartystreets/goconvey v1.8.1
require (
github.com/lim-yoona/msgpack v0.1.0
github.com/smartystreets/goconvey v1.8.1
)

require (
github.com/gopherjs/gopherjs v1.17.2 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ github.com/gopherjs/gopherjs v1.17.2 h1:fQnZVsXk8uxXIStYb0N4bGk7jeyTalG/wsZjQ25d
github.com/gopherjs/gopherjs v1.17.2/go.mod h1:pRRIvn/QzFLrKfvEz3qUuEhtE/zLCWfreZ6J5gM2i+k=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/lim-yoona/msgpack v0.1.0 h1:sAULeEVw0RpF9iujzIFzAYntuE/dFd9v6yLqhWZKAPU=
github.com/lim-yoona/msgpack v0.1.0/go.mod h1:w/GynN0+bueeewRWfznv51+auiQuX1O/BSp41dAHFWk=
github.com/smarty/assertions v1.15.0 h1:cR//PqUBUiQRakZWqBiFFQ9wb8emQGDb0HeGdqGByCY=
github.com/smarty/assertions v1.15.0/go.mod h1:yABtdzeQs6l1brC900WlRNwj6ZR55d7B+E8C6HtKdec=
github.com/smartystreets/goconvey v1.8.1 h1:qGjIddxOk4grTu9JPOU31tVfq3cNdBlNa5sSznIX1xY=
Expand Down
2 changes: 1 addition & 1 deletion message.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package msgpack
package tcpack

// Imessage is an interface that definds a message,
// which carries DataLen, MsgId and MsgData.
Expand Down
2 changes: 1 addition & 1 deletion msgpack.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package msgpack
package tcpack

import (
"bytes"
Expand Down
2 changes: 1 addition & 1 deletion msgpack_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package msgpack
package tcpack

import (
"fmt"
Expand Down

0 comments on commit 63dbc47

Please sign in to comment.