Golang builtin.len() function example

package builtin

The len built-in function returns the length of input vector, according to its type

Golang builtin.len() function usage example

 package main

 import (
 "os"
 "fmt"
 )

 func main () {

 if len(os.Args) != 3 { // check the length of the passed arguments
 fmt.Printf("Usage : %s argument1 argument2 \n ", os.Args[0]) 
 os.Exit(1) // graceful exit
 }
 }

Reference :

http://golang.org/pkg/builtin/#len

Advertisement