fork download
  1. package main
  2.  
  3. import (
  4. "fmt"
  5. "unicode"
  6. )
  7.  
  8. func main() {
  9. phrase := "is this loss?"
  10. //result := strings.Builder{} // You must be older than go1.10 :(
  11. result := make([]rune, len(phrase))
  12.  
  13. for i, j := range phrase {
  14. if i%2 == 1 {
  15. //result.WriteRune(unicode.ToLower(j))
  16. result[i] = unicode.ToLower(j)
  17. } else {
  18. //result.WriteRune(unicode.ToUpper(j))
  19. result[i] = unicode.ToUpper(j)
  20. }
  21. }
  22. //fmt.Println(result.String())
  23. fmt.Println(string(result))
  24. }
Success #stdin #stdout 0s 4520KB
stdin
Standard input is empty
stdout
Is tHiS LoSs?