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.

23 lines
252 B

  1. package main
  2. import "fmt"
  3. func message() string {
  4. m := ""
  5. arr := [4]int{1, 2, 3, 4}
  6. for i := 0; i < len(arr); i++ {
  7. arr[i] *= arr[i]
  8. m += fmt.Sprintf("%v: %v\n", i, arr[i])
  9. }
  10. return m
  11. }
  12. func main() {
  13. fmt.Print(message())
  14. }