Built-in function
Go len()
Reports byte length for strings, element count for arrays and slices, key count for maps, and queued element count for channels. Array pointers are also accepted. Nil slices, maps and channels have length zero. Example prints 2 for one UTF-8 rune.
Formal Syntax & Structure
go syntaxgo
len(v)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| v | string, array, array pointer, slice, map or channel | Value whose length is queried. |
Return Value
int
Length, sometimes a constant.
Working Example
Example Snippetgo
package main
import "fmt"
func main() { fmt.Println(len("é"))}