diff options
author | Dave Cheney <dave@cheney.net> | 2011-11-16 10:19:56 -0500 |
---|---|---|
committer | Adam Langley <agl@golang.org> | 2011-11-16 10:19:56 -0500 |
commit | 00f9b7680a8481e988b20414699fb25b0030079b (patch) | |
tree | 10fbfbd4f7fffbc231dfe2f2e2ef15741d32d5b0 | |
parent | 3307597069f533a1f34beadb735af804d47ef6de (diff) | |
download | go-00f9b7680a8481e988b20414699fb25b0030079b.tar.gz go-00f9b7680a8481e988b20414699fb25b0030079b.zip |
exp/ssh: fix unmarshal test
Ensure that empty NameLists always return
a zero length []string, not nil.
In practice NameLists are only used in a few
message types and always consumed by a for
range function so the difference between nil
and []string{} is not significant.
Also, add exp/ssh to pkg/Makefile as suggested
by rsc.
R=rsc, agl
CC=golang-dev
https://golang.org/cl/5400042
-rw-r--r-- | src/pkg/exp/ssh/messages.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/pkg/exp/ssh/messages.go b/src/pkg/exp/ssh/messages.go index e24b6398b5..169a8bf6b8 100644 --- a/src/pkg/exp/ssh/messages.go +++ b/src/pkg/exp/ssh/messages.go @@ -392,7 +392,10 @@ func parseString(in []byte) (out, rest []byte, ok bool) { return } -var comma = []byte{','} +var ( + comma = []byte{','} + emptyNameList = []string{} +) func parseNameList(in []byte) (out []string, rest []byte, ok bool) { contents, rest, ok := parseString(in) @@ -400,6 +403,7 @@ func parseNameList(in []byte) (out []string, rest []byte, ok bool) { return } if len(contents) == 0 { + out = emptyNameList return } parts := bytes.Split(contents, comma) |