func Test_Sum(t *testing.T) { a := []int{1, 2, 3} result := calc.Sum(a) //var b interface{} //b = a //fmt.Println(reflect.TypeOf(b)) //fmt.Println(b) fmt.Println(result) b := int(result.(int64)) fmt.Println(b) }
func Test_Sum_Float(t *testing.T) { a := []float32{1.5, 2.3, 3.6} result := calc.Sum(a) //var b interface{} //b = a //fmt.Println(reflect.TypeOf(b)) //fmt.Println(b) fmt.Println(result) fmt.Println(result.(float64)) b := float32(result.(float64)) fmt.Println(b) s := float32(0.0) for _, v := range a { s += v } fmt.Println(s) }
func main() { n, err := fmt.Println(calc.Sum(1, 2)) fmt.Println(n, err) }
func main() { fmt.Println(calc.Sum(1, 2)) // calc 패키지의 Sum 함수 사용 }
func main() { fmt.Println(stringutil.Reverse("olleh")) fmt.Println(calc.Sum(3, 2)) // calc 패키지의 Sum 함수 사용 }