trash.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package main
  2. import (
  3. "fmt"
  4. "strings"
  5. )
  6. func testStrings() {
  7. broken := "G# r#cks!"
  8. replacer := strings.NewReplacer("#", "o")
  9. fixed := replacer.Replace(broken)
  10. fmt.Println(fixed)
  11. }
  12. func testString() {
  13. v := "Hello"
  14. for i, c := range v {
  15. fmt.Printf("%d of '%s\n", i, string(c))
  16. }
  17. emoji := []rune("cool")
  18. for _, ch := range emoji {
  19. fmt.Printf("%d of '%s'\n", ch, string(ch))
  20. }
  21. }
  22. func testSlice() {
  23. }
  24. func main() {
  25. testString()
  26. /*
  27. var price int = 100.0
  28. fmt.Println("Price is", price, "dollars.")
  29. var taxRate float64 = 0.08
  30. var tax float64 = float64(price) * taxRate
  31. fmt.Println("Tax is", tax, "dollars")
  32. var total float64 = float64(price) + tax
  33. fmt.Println("Total cost is", total, "dollars")
  34. var aviableFunds int = 120
  35. fmt.Println(aviableFunds, "dollars available.")
  36. fmt.Println("Within budget?", total <= float64(aviableFunds))
  37. */
  38. /*
  39. var now time.Time = time.Now()
  40. var year int = now.Year()
  41. fmt.Println("Today is", year, "year")
  42. fmt.Println("Now is", time.Now())
  43. */
  44. // test_error()
  45. // testStrings()
  46. }