github.com/nibnait/go-learn@v0.0.0-20220227013611-dfa47ea6d2da/src/test/chapter/ch1/12_string_fun_test.go (about)

     1  package ch1
     2  
     3  import (
     4  	"strconv"
     5  	"strings"
     6  	"testing"
     7  )
     8  
     9  func TestStringFn(t *testing.T) {
    10  	s := "a,d,c"
    11  	parts := strings.Split(s, ",")
    12  	for _, part := range parts {
    13  		t.Log(part)
    14  	}
    15  
    16  	t.Logf(strings.Join(parts, "-"))
    17  }
    18  
    19  func TestStrConv(t *testing.T) {
    20  	s := strconv.Itoa(10)
    21  	t.Log("str" + s)
    22  
    23  	if atoi, err := strconv.Atoi("10"); err == nil {
    24  		t.Log(10 + atoi)
    25  	}
    26  }