Skip to content

Commit

Permalink
imp
Browse files Browse the repository at this point in the history
  • Loading branch information
shamaton committed Mar 16, 2024
1 parent 5c74e23 commit ae6efcd
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 17 deletions.
19 changes: 10 additions & 9 deletions .github/workflows/test.yml
Expand Up @@ -14,27 +14,28 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
go: ['1.19', '1.20', '1.21']
go: ['1.20', '1.21', '1.22']
name: ${{ matrix.os }} @ Go ${{ matrix.go }}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: ${{ env.WORKSPACE }}

- name: Set up Go ${{ matrix.go }}
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}

- name: Cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Checkout
uses: actions/checkout@v3
with:
path: ${{ env.WORKSPACE }}
- name: Build
run: go build -v ./...
Expand All @@ -43,7 +44,7 @@ jobs:
run: go test -v --coverpkg=github.com/shamaton/msgpack/... --coverprofile=coverage.coverprofile --covermode=atomic ./...

- name: Upload coverage to Codecov
if: success() && matrix.go == '1.21' && matrix.os == 'ubuntu-latest'
if: success() && matrix.go == '1.22' && matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@v1
with:
token:
Expand All @@ -55,7 +56,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: ${{ env.WORKSPACE }}
- name: golangci-lint
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018 Masayuki Shamoto
Copyright (c) 2024 Masayuki Shamoto

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
25 changes: 18 additions & 7 deletions README.md
Expand Up @@ -17,8 +17,6 @@ You can get the fastest performance with [msgpackgen](https://github.com/shamato
* Supports extend encoder / decoder
* Can also Encoding / Decoding struct as array

This package requires more than version **1.13**

## Installation

Current version is **msgpack/v2**.
Expand All @@ -32,24 +30,37 @@ package main

import (
"github.com/shamaton/msgpack/v2"
"net/http"
)

type Struct struct {
String string
}

// simple
func main() {
type Struct struct {
String string
}
v := Struct{String: "msgpack"}

d, err := msgpack.Marshal(v)
if err != nil {
panic(err)
}
r := Struct{}
err = msgpack.Unmarshal(d, &r)
if err != nil {
if err = msgpack.Unmarshal(d, &r); err != nil {
panic(err)
}
}

// streaming
func handle(w http.ResponseWriter, r *http.Request) {
var body Struct
if err := msgpack.UnmarshalRead(r, &body); err != nil {
panic(err)
}
if err := msgpack.MarshalWrite(w, body); err != nil {
panic(err)
}
}
```

## Benchmark
Expand Down

0 comments on commit ae6efcd

Please sign in to comment.