Go 구조체 슬라이스

1 개요[ | ]

Go 구조체 슬라이스
package main

import (
	"fmt"
)

func main() {
	fruits := []struct {
		id    int
		name  string
		price int
	}{
		{102, "apple", 30},
		{202, "banana", 20},
		{104, "melon", 20},
	}
	fmt.Println(fruits)         // [{102 apple 30} {202 banana 20} {104 melon 20}]
	fmt.Printf("%+v\n", fruits) // [{id:102 name:apple price:30} {id:202 name:banana price:20} {id:104 name:melon price:20}]
}

2 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}