mirror of
https://github.com/golang/go
synced 2024-11-20 02:24:43 -07:00
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
This commit is contained in:
parent
3307597069
commit
00f9b7680a
@ -392,7 +392,10 @@ func parseString(in []byte) (out, rest []byte, ok bool) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var comma = []byte{','}
|
var (
|
||||||
|
comma = []byte{','}
|
||||||
|
emptyNameList = []string{}
|
||||||
|
)
|
||||||
|
|
||||||
func parseNameList(in []byte) (out []string, rest []byte, ok bool) {
|
func parseNameList(in []byte) (out []string, rest []byte, ok bool) {
|
||||||
contents, rest, ok := parseString(in)
|
contents, rest, ok := parseString(in)
|
||||||
@ -400,6 +403,7 @@ func parseNameList(in []byte) (out []string, rest []byte, ok bool) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(contents) == 0 {
|
if len(contents) == 0 {
|
||||||
|
out = emptyNameList
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
parts := bytes.Split(contents, comma)
|
parts := bytes.Split(contents, comma)
|
||||||
|
Loading…
Reference in New Issue
Block a user