mirror of
https://github.com/jwetzell/osc-go.git
synced 2026-08-08 08:33:39 +00:00
some linting things
This commit is contained in:
@@ -72,19 +72,20 @@ func BundleFromBytes(bytes []byte) (*OSCBundle, []byte, error) {
|
||||
|
||||
bundleContentBytes := remainingBytes[0:contentSize]
|
||||
|
||||
if bundleContentBytes[0] == 35 {
|
||||
switch bundleContentBytes[0] {
|
||||
case 35: // #
|
||||
content, _, err := BundleFromBytes(bundleContentBytes)
|
||||
if err != nil {
|
||||
return nil, remainingBytes, err
|
||||
}
|
||||
bundleContents = append(bundleContents, content)
|
||||
} else if bundleContentBytes[0] == 47 {
|
||||
case 47: // /
|
||||
content, err := MessageFromBytes(bundleContentBytes)
|
||||
if err != nil {
|
||||
return nil, remainingBytes, err
|
||||
}
|
||||
bundleContents = append(bundleContents, content)
|
||||
} else {
|
||||
default:
|
||||
return nil, remainingBytes, errors.New("bundle contents does not look a bundle or message")
|
||||
}
|
||||
remainingBytes = bytesAfterContentSize[contentSize:]
|
||||
|
||||
@@ -141,11 +141,12 @@ func slipEncode(bytes []byte) []byte {
|
||||
var encodedBytes = []byte{END}
|
||||
|
||||
for _, byteToEncode := range bytes {
|
||||
if byteToEncode == END {
|
||||
switch byteToEncode {
|
||||
case END:
|
||||
encodedBytes = append(encodedBytes, ESC, ESC_END)
|
||||
} else if byteToEncode == ESC {
|
||||
case ESC:
|
||||
encodedBytes = append(encodedBytes, ESC, ESC_ESC)
|
||||
} else {
|
||||
default:
|
||||
encodedBytes = append(encodedBytes, byteToEncode)
|
||||
}
|
||||
}
|
||||
@@ -178,8 +179,5 @@ func makeMsg(address string, args []string, types []string, slip bool) {
|
||||
if slip {
|
||||
oscMessageBuffer = slipEncode(oscMessageBuffer)
|
||||
}
|
||||
|
||||
//TODO write buffer to stdout
|
||||
os.Stdout.Write(oscMessageBuffer)
|
||||
|
||||
}
|
||||
|
||||
@@ -120,9 +120,10 @@ func (s *SLIP) decode(bytes []byte) {
|
||||
}
|
||||
|
||||
if escapeNext {
|
||||
if packetByte == ESC_END {
|
||||
switch packetByte {
|
||||
case ESC_END:
|
||||
s.pendingBytes = append(s.pendingBytes, END)
|
||||
} else if packetByte == ESC_ESC {
|
||||
case ESC_ESC:
|
||||
s.pendingBytes = append(s.pendingBytes, ESC)
|
||||
}
|
||||
escapeNext = false
|
||||
|
||||
@@ -169,11 +169,12 @@ func slipEncode(bytes []byte) []byte {
|
||||
var encodedBytes = []byte{END}
|
||||
|
||||
for _, byteToEncode := range bytes {
|
||||
if byteToEncode == END {
|
||||
switch byteToEncode {
|
||||
case END:
|
||||
encodedBytes = append(encodedBytes, ESC, ESC_END)
|
||||
} else if byteToEncode == ESC {
|
||||
case ESC:
|
||||
encodedBytes = append(encodedBytes, ESC, ESC_ESC)
|
||||
} else {
|
||||
default:
|
||||
encodedBytes = append(encodedBytes, byteToEncode)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user