This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<title> | |
Articles | |
</title> | |
<body> | |
<h1>Articles page</h1> | |
<p><img src="images/images.jpg"/></p> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
// Function tp update maps | |
func updateNumbers(m map[string]int) { | |
m["three"] = 3 | |
m["four"] = 4 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
var mscores = make(map[string]int) | |
mscores["Chetan"] = 90 | |
mscores["John"] = 75 | |
mscores["Alice"] = 30 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
func main() { | |
var mscores = make(map[string]int) | |
mscores["Chetan"] = 90 | |
// Returns mscrores: map[Chetan:90] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"reflect" | |
) | |
func main() { | |
/* Declaring an array and adding elements */ | |
var names [3]string //string array with length 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
/* Function that doubles every element in the slice */ | |
func workonslice(slice []int) { | |
for i := range slice { | |
slice[i] *= 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"reflect" | |
"unsafe" | |
) | |
func main() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
var names []string /* Zero value of a slice is nil */ | |
fmt.Println(names, len(names), cap(names)) /* Returns [] 0 0 */ | |
names = append(names, "John", "Bill", "Steve") | |
fmt.Println(names, len(names), cap(names)) /* Returns [John Bill Steve] 3 3 */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
slices := []string{"AB", "CD", "EF"} | |
fmt.Println(slices) | |
array := [5]int{76, 77, 78, 79, 80} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
func main() { | |
/* Shorthand declaration */ | |
scores := [4]int{80, 85, 45, 55} |