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() { | |
/* Short hand declaration */ | |
mynames := [3]string{"Alice", "Bob", "Celine"} |
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 changeArray(numbers [5]int) { | |
numbers[0] = 55 /* Passed by value */ | |
fmt.Println("Changed numbers ::", numbers) |
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" | |
import "github.com/cjgiridhar/mathematics" | |
/*func add(a, b int) int { | |
return a+b | |
}*/ | |
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 mathematics | |
func Add(a,b int) int { | |
return a+b | |
} | |
func Sub(a,b int) int { | |
return a-b | |
} |
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 add(a, b int) int { | |
return a+b | |
} | |
func main() { | |
sum := add(4, 5) |
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 aStr() { | |
mstr1, mstr2 := "Hi", "Go!" | |
fmt.Printf("%s %s", mstr1, mstr2) | |
} | |
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 ( | |
pi float32 = 3.1416 //floating point number | |
z complex128 = -5 + 12i //complex number | |
) | |
/* creating a complex number */ |
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 myChar byte = 'A' //Stores ASCII characters | |
var myUnicode rune = '♥' //Stores Unicode characters | |
fmt.Printf("%c = %d and %c = %U\n", myChar, myChar, myUnicode, myUnicode) | |
} |
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() { | |
/* Assignment */ | |
var isBool = true | |
var isActive bool //is_active is set to false | |
var isTrue = 1 <= 5 // as 1<=5 is true, isTrue variable is set to true |