Standard library / bytes
bytes.Equal()
Tests equality byte by byte; nil and empty byte slices compare equal. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
func Equal(a, b []byte) boolParameters & Attributes
| Name | Type | Description |
|---|---|---|
| a | []byte | First input to compare. |
| b | []byte | Second input to compare. |
Return Value
bool
Tests equality byte by byte; nil and empty byte slices compare equal.
Working Example
Example Snippetgo
package main
import ( "bytes" "fmt")
func main() { fmt.Println(bytes.Equal(nil, []byte{}))}