WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

Go - Range


The range catchphrase is utilized in for circle to emphasize over things of an exhibit, cut, channel or guide. With cluster and cuts, it restores the list of the thing as whole number. With maps, it restores the essential thing of the following key-value pair.
Range expression 1st Value second Value(Optional)
Array or cut a [n]E index I int a[i] E
String s string kind index I int rune int
map m map[K]V key alright K fee m[k] V
channel c chan E element e E none

Example

The accompanying passage proposes how to utilize go
package critical 

import "fmt" 

func generally essential() 

/* make a cut */ 

numbers := []int0,1,2,3,4,5 

/* print the numbers */ 

for i:= assortment numbers 

fmt.Println("Slice item",i,"is",numbers[i]) 

/* make a map*/ 

countryCapitalMap := map[string] string "France":"Paris","USA":"Washington D.C.","India":"Delhi" 

/* print map the use of keys*/ 

for us of a := extend countryCapitalMap 

fmt.Println("Capital of",u . S . An .,"is",countryCapitalMap[country]) 

/* print map utilizing key-fee*/ 

for joined conditions of america,capital := go countryCapitalMap 

fmt.Println("Capital of",united states,"is",capital) 

At the point when the above code is incorporated and completed, it creates the consequent outcome
 

$move run main.Cross 

Cut article zero will be zero 

Cut thing 1 will be 1 

Cut thing 2 will be 2 

Cut thing 3 will be 3 

Cut item four will be four 

Cut item five is 5 

Capital of France is Paris 

Capital of USA is Washington D.C. 

Capital of India is Delhi 

Capital of France is Paris 

Capital of USA is Washington D.C. 

Capital of India is Delhi