| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- package main
- import (
- "fmt"
- "strings"
- )
- func testStrings() {
- broken := "G# r#cks!"
- replacer := strings.NewReplacer("#", "o")
- fixed := replacer.Replace(broken)
- fmt.Println(fixed)
- }
- func testString() {
- v := "Hello"
- for i, c := range v {
- fmt.Printf("%d of '%s\n", i, string(c))
- }
- emoji := []rune("cool")
- for _, ch := range emoji {
- fmt.Printf("%d of '%s'\n", ch, string(ch))
- }
- }
- func testSlice() {
-
- }
- func main() {
- testString()
- /*
- var price int = 100.0
- fmt.Println("Price is", price, "dollars.")
- var taxRate float64 = 0.08
- var tax float64 = float64(price) * taxRate
- fmt.Println("Tax is", tax, "dollars")
- var total float64 = float64(price) + tax
- fmt.Println("Total cost is", total, "dollars")
- var aviableFunds int = 120
- fmt.Println(aviableFunds, "dollars available.")
- fmt.Println("Within budget?", total <= float64(aviableFunds))
- */
- /*
- var now time.Time = time.Now()
- var year int = now.Year()
- fmt.Println("Today is", year, "year")
- fmt.Println("Now is", time.Now())
- */
- // test_error()
- // testStrings()
- }
|