Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

Length of slice in Go

len function can be used to get the length of slice.

Syntax
len(sliceName)


Example : Get length of slice
package main

import "fmt"

func main() {

    personNameSlice := make([]string, 0)

    personNameSlice = append(personNameSlice, "hello")

    fmt.Printf("%v", len(personNameSlice))

}



Output
1