Skip to content
This repository was archived by the owner on Jul 21, 2021. It is now read-only.

Commit d0d0e64

Browse files
authoredAug 1, 2019
Fix struct encode and decode for Go 1.13 (#216)
Fixes #215
1 parent 758ce21 commit d0d0e64

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed
 

‎.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
language: go
22
go:
3-
- 1.11
4-
- 1.9
3+
- "1.11"
4+
- "1.x"
55
- tip
66

77
go_import_path: github.com/samuel/go-zookeeper

‎zk/structs.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"log"
77
"reflect"
88
"runtime"
9+
"strings"
910
"time"
1011
)
1112

@@ -404,7 +405,7 @@ type encoder interface {
404405
func decodePacket(buf []byte, st interface{}) (n int, err error) {
405406
defer func() {
406407
if r := recover(); r != nil {
407-
if e, ok := r.(runtime.Error); ok && e.Error() == "runtime error: slice bounds out of range" {
408+
if e, ok := r.(runtime.Error); ok && strings.HasPrefix(e.Error(), "runtime error: slice bounds out of range") {
408409
err = ErrShortBuffer
409410
} else {
410411
panic(r)
@@ -495,7 +496,7 @@ func decodePacketValue(buf []byte, v reflect.Value) (int, error) {
495496
func encodePacket(buf []byte, st interface{}) (n int, err error) {
496497
defer func() {
497498
if r := recover(); r != nil {
498-
if e, ok := r.(runtime.Error); ok && e.Error() == "runtime error: slice bounds out of range" {
499+
if e, ok := r.(runtime.Error); ok && strings.HasPrefix(e.Error(), "runtime error: slice bounds out of range") {
499500
err = ErrShortBuffer
500501
} else {
501502
panic(r)

0 commit comments

Comments
 (0)
This repository has been archived.