Skip to content

Commit

Permalink
Drop use of go-restruct/restruct (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkmueller authored Jan 5, 2022
1 parent 1369b2e commit 0de7f92
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 21 deletions.
5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module github.com/knqyf263/go-rpmdb
go 1.14

require (
github.com/go-restruct/restruct v0.0.0-20191227155143-5734170a48a1
github.com/stretchr/testify v1.4.0
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543
github.com/stretchr/testify v1.7.0
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
)
16 changes: 6 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-restruct/restruct v0.0.0-20191227155143-5734170a48a1 h1:LoN2wx/aN8JPGebG+2DaUyk4M+xRcqJXfuIbs8AWHdE=
github.com/go-restruct/restruct v0.0.0-20191227155143-5734170a48a1/go.mod h1:KqrpKpn4M8OLznErihXTGLlsXFGeLxHUrLRRI/1YjGk=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
5 changes: 3 additions & 2 deletions pkg/bdb/generic_page.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package bdb

import (
"bytes"
"encoding/binary"
"github.com/go-restruct/restruct"
"golang.org/x/xerrors"
)

Expand All @@ -29,7 +29,8 @@ type GenericMetadataPage struct {
func ParseGenericMetadataPage(data []byte) (*GenericMetadataPage, error) {
var metadata GenericMetadataPage

err := restruct.Unpack(data, binary.LittleEndian, &metadata)
err := binary.Read(bytes.NewReader(data), binary.LittleEndian, &metadata)

if err != nil {
return nil, xerrors.Errorf("failed to unpack GenericMetadataPage: %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/bdb/hash_metadata_page.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package bdb

import (
"bytes"
"encoding/binary"
"github.com/go-restruct/restruct"
"golang.org/x/xerrors"
)

Expand All @@ -21,7 +21,7 @@ type HashMetadataPage struct {
func ParseHashMetadataPage(data []byte) (*HashMetadataPage, error) {
var metadata HashMetadataPage

err := restruct.Unpack(data, binary.LittleEndian, &metadata)
err := binary.Read(bytes.NewReader(data), binary.LittleEndian, &metadata)
if err != nil {
return nil, xerrors.Errorf("failed to unpack HashMetadataPage: %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/bdb/hash_page.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package bdb

import (
"bytes"
"encoding/binary"
"github.com/go-restruct/restruct"
"golang.org/x/xerrors"
"io"
"os"
Expand All @@ -23,7 +23,7 @@ type HashPage struct {
func ParseHashPage(data []byte) (*HashPage, error) {
var hashPage HashPage

err := restruct.Unpack(data, binary.LittleEndian, &hashPage)
err := binary.Read(bytes.NewReader(data), binary.LittleEndian, &hashPage)
if err != nil {
return nil, xerrors.Errorf("failed to unpack: %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/bdb/hash_page_entry.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package bdb

import (
"bytes"
"encoding/binary"
"github.com/go-restruct/restruct"
"golang.org/x/xerrors"
)

Expand All @@ -17,7 +17,7 @@ type HashOffPageEntry struct {
func ParseHashOffPageEntry(data []byte) (*HashOffPageEntry, error) {
var entry HashOffPageEntry

err := restruct.Unpack(data, binary.LittleEndian, &entry)
err := binary.Read(bytes.NewReader(data), binary.LittleEndian, &entry)
if err != nil {
return nil, xerrors.Errorf("failed to unpack HashOffPageEntry: %w", err)
}
Expand Down

0 comments on commit 0de7f92

Please sign in to comment.