a := 4
b := 6
if a + b == 10 {
fmt.Println("a + b is equal to 10!")
} else {
fmt.Println("a + b does not equal 10...")
}
if num < 0 {
fmt.Println(num, "is negative")
} else if num < 10 {
fmt.Println(num, "has 1 digit")
} else {
fmt.Println(num, "has multiple digits")
}
}
package main
import "fmt"
func main() {
name := "Manager"
if name == "Manager" {
fmt.Println("This is the Manager")
} else {
fmt.Println("This is not the manager")
}
}
if _, err := doThing(); err != nil {
fmt.Println("Uh oh")
}
if x := f(); x <= y {
return x
}
if x > max {
x = max
}
if x <= y {
min = x
} else {
min = y
}
if x := f(); x < y {
return x
} else if x > z {
return z
} else {
return y
}
res = expr ? x : y
if expr {
res = x
} else {
res = y
}
func Min(x, y int) int {
if x <= y {
return x
}
return y
}
// Program to display a number if it is positive
package main
import "fmt"
func main() {
number := 15
// true if number is less than 0
if number > 0 {
fmt.Printf("%d is a positive number
", number)
}
fmt.Println("Out of the loop")
}
package main
import "fmt"
func main() {
number := 10
// checks if number is greater than 0
if number > 0 {
fmt.Printf("%d is a positive number
", number)
} else {
fmt.Printf("%d is a negative number
", number)
}
}
if num := 9; num < 0 {
fmt.Println(num, "is negative")
} else if num < 10 {
fmt.Println(num, "has 1 digit")
} else {
fmt.Println(num, "has multiple digits")
}