Standard library / bytes
bytes.Clone()
Returns a copy of the input byte slice; nil input returns nil. The result can be retained independently of later input mutation. Expected stdout: 'hello\n'.
Formal Syntax & Structure
go syntaxgo
func Clone(b []byte) []byteParameters & Attributes
| Name | Type | Description |
|---|---|---|
| b | []byte | Byte sequence or second comparison input. |
Return Value
[]byte
Returns a copy of the input byte slice; nil input returns nil. The result can be retained independently of later input mutation.
Working Example
Example Snippetgo
package main
import ( "bytes" "fmt")
func main() { fmt.Println(string(bytes.Clone([]byte("hello"))))}