Exemple #1
0
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)
}
Exemple #2
0
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)
}
Exemple #3
0
func main() {
	n, err := fmt.Println(calc.Sum(1, 2))
	fmt.Println(n, err)
}
Exemple #4
0
func main() {
	fmt.Println(calc.Sum(1, 2)) // calc 패키지의 Sum 함수  사용
}
Exemple #5
0
func main() {
	fmt.Println(stringutil.Reverse("olleh"))
	fmt.Println(calc.Sum(3, 2)) // calc 패키지의 Sum 함수 사용
}