add: slice exercises

This commit is contained in:
Inanc Gumus
2019-01-22 20:32:32 +03:00
parent d2be3d6692
commit 69fe30b2ee
15 changed files with 210 additions and 83 deletions

View File

@ -0,0 +1,26 @@
// For more tutorials: https://blog.learngoprogramming.com
//
// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
package main
import "fmt"
func main() {
names := []string{"Einstein", "Tesla", "Shepard"}
distances := []int{50, 40, 75, 30, 125}
data := []byte{'H', 'E', 'L', 'L', 'O'}
ratios := []float64{3.14145}
alives := []bool{true, false, true, false}
zero := []byte{}
fmt.Printf("names : %[1]T %[1]q\n", names)
fmt.Printf("distances: %[1]T %[1]d\n", distances)
fmt.Printf("data : %[1]T %[1]d\n", data)
fmt.Printf("ratios : %[1]T %[1].2f\n", ratios)
fmt.Printf("alives : %[1]T %[1]t\n", alives)
fmt.Printf("zero : %[1]T %[1]d\n", zero)
}