diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ebf603e..17c7366 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 ./... @@ -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: @@ -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 diff --git a/LICENSE b/LICENSE index 4b5e3c1..a5810ed 100644 --- a/LICENSE +++ b/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 diff --git a/README.md b/README.md index 206e768..a8aa22f 100644 --- a/README.md +++ b/README.md @@ -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**. @@ -32,12 +30,15 @@ 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) @@ -45,11 +46,21 @@ func main() { 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