Learning GO
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
const name = "Sara"
|
||||
|
||||
love := "Kahlousha"
|
||||
number := 43900900
|
||||
|
||||
func main() {
|
||||
|
||||
const world = "Mykids"
|
||||
fmt.Println("Hello,", world)
|
||||
|
||||
fmt.Println("I love ", name)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
module hello
|
||||
|
||||
go 1.23.1
|
||||
@@ -0,0 +1,27 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
const (
|
||||
// Create a huge number by shifting a 1 bit left 100 places.
|
||||
// In other words, the binary number that is 1 followed by 100 zeroes.
|
||||
Big = 1 << 100
|
||||
|
||||
//shoft it right 99 places
|
||||
Small = Big >> 99
|
||||
)
|
||||
|
||||
func needInt(x int) int {
|
||||
return x*10 + 1
|
||||
}
|
||||
|
||||
func needFloat(y float64) float64 { return y * 0.1 }
|
||||
|
||||
func main() {
|
||||
fmt.Println(Small)
|
||||
fmt.Println(needInt(Small))
|
||||
fmt.Println(needFloat(Small))
|
||||
fmt.Println(needFloat(Big))
|
||||
}
|
||||
Reference in New Issue
Block a user