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) bool

Parameters & Attributes

NameTypeDescription
a[]byteFirst input to compare.
b[]byteSecond 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{}))}
Go Reference