From 138215002e5daa3443e70b36ed63f960545a7f14 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Thu, 24 Dec 2015 18:49:33 +0200 Subject: [PATCH] Added 'src = src[:0]' hack for nil src into readme --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6869eae5f9..1115a39ace 100644 --- a/README.md +++ b/README.md @@ -373,10 +373,11 @@ var ( dst []byte src []byte ) -dst = append(dst, src...) // is legal if dst is nil and src is nil -copy(dst, src) // is legal if dst is nil and src is nil +dst = append(dst, src...) // is legal if dst is nil and/or src is nil +copy(dst, src) // is legal if dst is nil and/or src is nil (string(src) == "") // is true if src is nil (len(src) == 0) // is true if src is nil +src = src[:0] // works like a charm with nil src // this for loop doesn't panic if src is nil for i, ch := range src {