github.com/vanus-labs/vanus/lib@v0.0.0-20231221070800-1334a7b9605e/bytes/clone_go119.go (about)

     1  // SPDX-FileCopyrightText: 2023 Linkall Inc.
     2  //
     3  // SPDX-License-Identifier: Apache-2.0
     4  
     5  //go:build !go1.20
     6  
     7  package bytes
     8  
     9  // Clone returns a copy of b[:len(b)].
    10  // The result may have additional unused capacity.
    11  // Clone(nil) returns nil.
    12  func Clone(b []byte) []byte {
    13  	if b == nil {
    14  		return nil
    15  	}
    16  	return append([]byte{}, b...)
    17  }