FAQ
Yes. You need *T if you want to modify it's fields, just T if you only to
read them.
"Every thing in Go is referred by value"
On Sunday, 26 May 2013 21:35:57 UTC+5:30, Nguyên Nguyễn Văn Cao wrote:

For example I have a struct *Item* in my db, and two function *GetAllItem*which return more than one Item and
*GetLastItem* return one lasted Item.
GetAllItem will return a slice of Item and and error if any
func GetAllItem() ([]Item, error)

So I can return a nil slice if any error occur.
Now is my wonder about GetLastItem:
func GetLastItem() (*Item, error)

So I will able to return a nil Item, but it not analog with GetAllItem, so
should I change the GetAllItem to return a slice of *Item?
func GetAllItem() ([]*Item, error)

The Go GC is great, so we can go around and throw garbage everywhere?
Thanks!
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 7 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedMay 26, '13 at 4:06p
activeMay 26, '13 at 4:41p
posts7
users6
websitegolang.org

People

Translate

site design / logo © 2023 Grokbase