@ -0,0 +1,17 @@ | |||||
package main | |||||
import ( | |||||
"fmt" | |||||
"time" | |||||
) | |||||
func main() { | |||||
Debug := false | |||||
LogLevel := "info" | |||||
startUpTime := time.Now() | |||||
fmt.Println(Debug, LogLevel, startUpTime) | |||||
} |
@ -0,0 +1,21 @@ | |||||
package main | |||||
import ( | |||||
"fmt" | |||||
"time" | |||||
) | |||||
func getConfig() (bool, string, time.Time) { | |||||
return false, "info", time.Now() | |||||
} | |||||
func main() { | |||||
Debug, LogLevel, startUpTime := getConfig() | |||||
fmt.Println(Debug, LogLevel, startUpTime) | |||||
} |
@ -0,0 +1,19 @@ | |||||
package main | |||||
import "fmt" | |||||
var defaultOffset = 10 | |||||
func main() { | |||||
offset := 5 | |||||
fmt.Println(offset) | |||||
offset = 10 | |||||
fmt.Println(offset) | |||||
offset = offset + defaultOffset | |||||
fmt.Println(offset) | |||||
} |
@ -0,0 +1,12 @@ | |||||
package main | |||||
import "fmt" | |||||
func main() { | |||||
query, limit, offset := "bat", 10, 0 | |||||
query, limit, offset = "ball", offset, 20 | |||||
fmt.Println(query, limit, offset) | |||||
} |
@ -0,0 +1,39 @@ | |||||
package main | |||||
import "fmt" | |||||
func main() { | |||||
// Main course | |||||
var total float64 = 2 * 13 | |||||
fmt.Println("Sub:", total) | |||||
// Drinks | |||||
total = total + (4 * 2.25) | |||||
fmt.Println("Sub:", total) | |||||
// Discount | |||||
total = total - 5 | |||||
fmt.Println("Sub:", total) | |||||
// 10% Tip | |||||
tip := total * 0.1 | |||||
fmt.Println("Tip:", tip) | |||||
total = total + tip | |||||
fmt.Println("Total:", total) | |||||
// Split bill | |||||
split := total / 2 | |||||
fmt.Println("Split:", split) | |||||
// Reward every 5th visit | |||||
visitCount := 24 | |||||
visitCount = visitCount + 1 | |||||
remainder := visitCount % 5 | |||||
if remainder == 0 { | |||||
fmt.Println("With this visit, you've earned a reward.") | |||||
} | |||||
} |
@ -0,0 +1,22 @@ | |||||
package main | |||||
import "fmt" | |||||
func main() { | |||||
count := 5 | |||||
count += 5 | |||||
fmt.Println(count) | |||||
count++ | |||||
fmt.Println(count) | |||||
count-- | |||||
fmt.Println(count) | |||||
count -= 5 | |||||
fmt.Println(count) | |||||
name := "John" | |||||
name += " Smith" | |||||
fmt.Println(name) | |||||
} |
@ -0,0 +1,15 @@ | |||||
package main | |||||
import "fmt" | |||||
func main() { | |||||
visits := 15 | |||||
fmt.Println("First visit :", visits == 1) | |||||
fmt.Println("Return visit :", visits != 1) | |||||
fmt.Println("Silver member :", visits >= 10 && visits < 21) | |||||
fmt.Println("Gold member :", visits > 20 && visits <= 30) | |||||
fmt.Println("Platinum member:", visits > 30) | |||||
} |
@ -0,0 +1,29 @@ | |||||
package main | |||||
import ( | |||||
"fmt" | |||||
"time" | |||||
) | |||||
func main() { | |||||
var count int | |||||
fmt.Printf("Count: %#v \n", count) | |||||
var discount float64 | |||||
fmt.Printf("Discount: %#v \n", discount) | |||||
var debug bool | |||||
fmt.Printf("Debug: %#v \n", debug) | |||||
var msg string | |||||
fmt.Printf("Msg: %#v \n", msg) | |||||
var emails []string | |||||
fmt.Printf("eMails: %#v \n", emails) | |||||
var startTime time.Time | |||||
fmt.Printf("Start: %#v \n", startTime) | |||||
} |
@ -0,0 +1,22 @@ | |||||
package main | |||||
import ( | |||||
"fmt" | |||||
"time" | |||||
) | |||||
func main() { | |||||
var count1 *int | |||||
count2 := new(int) | |||||
countTemp :=5 | |||||
count3 := &countTemp | |||||
t := &time.Time{} | |||||
fmt.Printf("count1: %#v\n", count1) | |||||
fmt.Printf("count2: %#v\n", count2) | |||||
fmt.Printf("count3: %#v\n", count3) | |||||
fmt.Printf("time : %#v\n", t) | |||||
} |