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.

28 lines
492 B

  1. package main
  2. import "fmt"
  3. func main() {
  4. username := "Sir_King_Über"
  5. // Print bytes directly
  6. for i := 0; i < len(username); i++ {
  7. fmt.Print(username[i], " ")
  8. }
  9. fmt.Printf("\n")
  10. // Print bytes converted to string
  11. for i := 0; i < len(username); i++ {
  12. fmt.Print(string(username[i]), " ")
  13. }
  14. fmt.Printf("\n")
  15. // Print bytes converted to runes
  16. runes := []rune(username)
  17. for _, value := range runes {
  18. fmt.Print(string(value), " ")
  19. }
  20. fmt.Printf("\n")
  21. }