]> Cypherpunks repositories - gostls13.git/commitdiff
exp/ssh: fix unmarshal test
authorDave Cheney <dave@cheney.net>
Wed, 16 Nov 2011 15:19:56 +0000 (10:19 -0500)
committerAdam Langley <agl@golang.org>
Wed, 16 Nov 2011 15:19:56 +0000 (10:19 -0500)
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

src/pkg/exp/ssh/messages.go

index e24b6398b56fbd57fc349570634b5834e5edf09d..169a8bf6b811c3261ba327d113b938eaa127d374 100644 (file)
@@ -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)