-
Notifications
You must be signed in to change notification settings - Fork 0
/
switch01.go
25 lines (21 loc) · 846 Bytes
/
switch01.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package main
import (
"fmt"
"runtime"
"strings"
)
func main() {
var tVal string = "hello"
// init gover
var gover string = runtime.Version()
switch {
case strings.Contains(gover,"go1.17"): // if matches "go1.17", do the code below then STOP
fmt.Println("You are using the latest version of GoLang")
case strings.Contains(gover,"go1.16"),strings.Contains(gover, "go1.16.5"),strings.Contains(gover, "go1.15"): // if matches "go1.16", "go1.16.5", OR "go1.15"
fmt.Println("You are using an older, but acceptable version of GoLang")
case strings.Contains(tVal, "hello"):
fmt.Println("Does it Print ?")
default: // in all other cases run the code below
fmt.Println("I cannot make a recommendation.")
}
}