Exercises & activities from the go workshop provided by Packt: https://courses.packtpub.com/courses/go
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

21 lines
411 B

package main
import "fmt"
func message() string {
s := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}
m := fmt.Sprintln("First: ", s[0], s[0:1], s[:1])
m += fmt.Sprintln("Last: ", s[len(s)-1], s[len(s)-1:len(s)], s[len(s)-1:])
m += fmt.Sprintln("First 5: ", s[:5])
m += fmt.Sprintln("Last 4: ", s[len(s)-4:])
m += fmt.Sprintln("Middle 5:", s[2:7])
return m
}
func main() {
fmt.Print(message())
}