소스 검색

Merge pull request #32156 from cpuguy83/index_copy_new_slice

Don't pass reference to mutable slice
Vincent Demeester 8 년 전
부모
커밋
95510551ce
1개의 변경된 파일6개의 추가작업 그리고 1개의 파일을 삭제
  1. 6 1
      pkg/registrar/registrar.go

+ 6 - 1
pkg/registrar/registrar.go

@@ -98,7 +98,12 @@ func (r *Registrar) GetNames(key string) ([]string, error) {
 	if !exists {
 		return nil, ErrNoSuchKey
 	}
-	return names, nil
+
+	ls := make([]string, 0, len(names))
+	for _, n := range names {
+		ls = append(ls, n)
+	}
+	return ls, nil
 }
 
 // Get returns the key that the passed in name is reserved to