main 함수에서 fmt.Println() 함수를 실행하면 String() 메서드에서 지정한 문자열이 출력된다.
func main() { shirt := Item{"Men's Slim-Fit Shirt", 25000, 3} video := Rental{"Interstellar", 1000, 3, Days} eventShoes := DiscountItem{ Item{"Women's Walking Shoes", 50000, 3}, 10.00, } items := Items{shirt, video, eventShoes} fmt.Println(shirt) fmt.Println(video) fmt.Println(eventShoes) fmt.Println(items) }
실행 결과
[Men's Slim-Fit Shirt] 75000 [Interstellar] 3000 [Women's Walking Shoes] 150000 => 135000(10% DC) 3 items. total: 213000 - [Men's Slim-Fit Shirt] 75000 - [Interstellar] 3000 - [Women's Walking Shoes] 150000 => 135000(10% DC)