Skip to content

Commit 631791f

Browse files
committed
chore: update go-version to 1.23.2
1 parent 6ccb62a commit 631791f

File tree

8 files changed

+496
-10
lines changed

8 files changed

+496
-10
lines changed

.github/workflows/codecov.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
name: Codecov
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
pull_request:
9+
branches:
10+
- main
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: actions/setup-go@v5
18+
with:
19+
go-version: "1.23"
20+
- name: Run coverage
21+
run: go test -race -coverprofile=coverage.txt -covermode=atomic
22+
- name: Upload coverage reports to Codecov
23+
uses: codecov/codecov-action@v4
24+
with:
25+
verbose: true
26+
env:
27+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

binutil/binutil.go

+8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"encoding/gob"
77
"errors"
88
"fmt"
9+
"io/fs"
910
"math"
1011
"math/big"
1112
"math/rand"
@@ -295,3 +296,10 @@ func Load(path string, object interface{}) error {
295296
file.Close()
296297
return err
297298
}
299+
300+
// LoadEmbed loads gob from embed.FS
301+
func LoadEmbed(f fs.File, object interface{}) error {
302+
decoder := gob.NewDecoder(f)
303+
err := decoder.Decode(object)
304+
return err
305+
}

cmd/uiigen/epc.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ func MakeGIAI96(pf bool, fv string, cp string, iar string) ([]byte, string, stri
203203
bs = append(bs, indivisualAssetReference...)
204204

205205
if len(bs) != 88 {
206-
return []byte{}, "", "", errors.New("len(bs): " + string(len(bs)))
206+
return []byte{}, "", "", fmt.Errorf("len(bs): %d", len(bs))
207207
}
208208

209209
p, err := binutil.ParseBinRuneSliceToUint8Slice(bs)
@@ -270,7 +270,7 @@ func MakeGRAI96(pf bool, fv string, cp string, at string, ser string) ([]byte, s
270270
bs = append(bs, serial...)
271271

272272
if len(bs) != 88 {
273-
return []byte{}, "", "", errors.New("len(bs): " + string(len(bs)))
273+
return []byte{}, "", "", fmt.Errorf("len(bs): %d", len(bs))
274274
}
275275

276276
p, err := binutil.ParseBinRuneSliceToUint8Slice(bs)
@@ -336,7 +336,7 @@ func MakeSGTIN96(pf bool, fv string, cp string, ir string, ser string) ([]byte,
336336
bs = append(bs, serial...)
337337

338338
if len(bs) != 88 {
339-
return []byte{}, "", "", errors.New("len(bs): " + string(len(bs)))
339+
return []byte{}, "", "", fmt.Errorf("len(bs): %d", len(bs))
340340
}
341341

342342
p, err := binutil.ParseBinRuneSliceToUint8Slice(bs)
@@ -397,7 +397,7 @@ func MakeSSCC96(pf bool, fv string, cp string, ext string) ([]byte, string, stri
397397
bs = append(bs, reserved...)
398398

399399
if len(bs) != 88 {
400-
return []byte{}, "", "", errors.New("len(bs): " + string(len(bs)))
400+
return []byte{}, "", "", fmt.Errorf("len(bs): %d", len(bs))
401401
}
402402

403403
p, err := binutil.ParseBinRuneSliceToUint8Slice(bs)

cover.cov

+439
Large diffs are not rendered by default.

go-llrp.test

4.16 MB
Binary file not shown.

go.mod

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
module github.com/iomz/go-llrp
22

3-
go 1.14
3+
go 1.23
4+
5+
require gopkg.in/alecthomas/kingpin.v2 v2.2.6
46

57
require (
68
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc // indirect
79
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf // indirect
810
github.com/stretchr/testify v1.5.1 // indirect
9-
gopkg.in/alecthomas/kingpin.v2 v2.2.6
1011
)

go.sum

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H
1111
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
1212
gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=
1313
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
14-
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
1514
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
1615
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
1716
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

llrp_test.go

+15-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2018 Iori Mizutani
1+
// Copyright (c) 2024 Iori Mizutani
22
//
33
// Use of this source code is governed by The MIT License
44
// that can be found in the LICENSE file.
@@ -7,13 +7,20 @@ package llrp
77

88
import (
99
"bytes"
10+
"embed"
11+
_ "embed"
1012
"math/rand"
1113
"os"
1214
"testing"
1315

1416
"github.com/iomz/go-llrp/binutil"
1517
)
1618

19+
var (
20+
//go:embed test/data/1000-tags.gob
21+
TestTags1000 embed.FS
22+
)
23+
1724
var packtests = []struct {
1825
in []interface{}
1926
out []byte
@@ -33,11 +40,15 @@ func TestPack(t *testing.T) {
3340
}
3441

3542
func TestUnmarshalROAccessReportBody(t *testing.T) {
36-
largeTagsGOB := os.Getenv("GOPATH") + "/src/github.com/iomz/go-llrp/test/data/1000-tags.gob"
3743
size := 100
3844
// load up the tags from the file
3945
var largeTags Tags
40-
binutil.Load(largeTagsGOB, &largeTags)
46+
f, err := TestTags1000.Open("test/data/1000-tags.gob")
47+
if err != nil {
48+
t.Error(err)
49+
}
50+
defer f.Close()
51+
binutil.LoadEmbed(f, &largeTags)
4152

4253
// cap the tags with the given size
4354
var limitedTags Tags
@@ -53,6 +64,7 @@ func TestUnmarshalROAccessReportBody(t *testing.T) {
5364
}
5465
}
5566

67+
t.Logf("limitedTags: %d", len(limitedTags))
5668
// build ROAR message
5769
pdu := int(1500)
5870
trds := limitedTags.BuildTagReportDataStack(pdu)

0 commit comments

Comments
 (0)