This file contains hidden or 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
// Function in golang where we pass 2 values to get the added value | |
func add (a int ,b int) (int,int) { | |
return a+b,a*b | |
} | |
//In golang to export a function or variable , struct or function u can just capotalise the initial letter of that member | |
func Add (a int ,b int) (int,int) { | |
return a+b,a*b //NOW IN THIS CASE IT BECOMES EXPORTABLE FUNCTION. |
This file contains hidden or 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
func main(){ | |
//Arrays in Golang | |
my_array := [5]int{1,2,3,4,5} // just like othesrs , arrays in go are 0 indexed. | |
//multidimensional arrys | |
matrix := [2][3]int{ | |
{1,2,3}, | |
{4,5,6}, | |
} | |
This file contains hidden or 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
func main(){ | |
type Person struct { //its a defined struct | |
Name string | |
ID int | |
Address Address //types of a property can be itself a struct | |
Contact string | |
} | |
employee := Employeeinfo{ // This is an anonymous struct where along with type u actually initialise the data. |