Skip to content

Commit

Permalink
NO-ISSUE Rename parse optional Body -> Param (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
bachhh authored Oct 14, 2021
1 parent d7dd071 commit a587369
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion connect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
var currentAuth int32

var auths = [][2]string{
{"491328", "79d474"},
{"689528", "1a97ae"},
}

const (
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module github.com/linxGnu/gosmpp

require (
github.com/stretchr/testify v1.7.0
golang.org/x/text v0.3.7
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/testify v1.7.0
golang.org/x/text v0.3.5
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
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/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
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=
Expand Down
15 changes: 6 additions & 9 deletions pdu/PDU.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,12 @@ func (c *base) unmarshal(b *ByteBuffer, bodyReader func(*ByteBuffer) error) (err
return
}

// have optional body?
// body < command_length, still have optional parameters ?
if got < cmdLength {

// the rest is optional body
var optionalBody []byte
if optionalBody, err = b.ReadN(cmdLength - got); err == nil {
err = c.unmarshalOptionalBody(optionalBody)
var optParam []byte
if optParam, err = b.ReadN(cmdLength - got); err == nil {
err = c.unmarshalOptionalParam(optParam)
}

if err != nil {
return
}
Expand All @@ -107,8 +104,8 @@ func (c *base) unmarshal(b *ByteBuffer, bodyReader func(*ByteBuffer) error) (err
return
}

func (c *base) unmarshalOptionalBody(body []byte) (err error) {
buf := NewBuffer(body)
func (c *base) unmarshalOptionalParam(optParam []byte) (err error) {
buf := NewBuffer(optParam)
for buf.Len() > 0 {
var field Field
if err = field.Unmarshal(buf); err == nil {
Expand Down

0 comments on commit a587369

Please sign in to comment.