FAQ
What is the idiomatic way to create a list that I'm uncertain of what the
end size will be and fill it with structs?

I'm a bit lost as to what the best way to do this is, and I have a a
feeling that "container/list" is a bit overkill.

But also, having an empty array and then continuing to append one struct
after another in my for loop seems to be not the best way either.

Thoughts?

--
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 golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Jesse McNelis at Sep 2, 2013 at 2:22 am

    On Sun, Sep 1, 2013 at 11:16 PM, Daniel Alan Miller wrote:

    What is the idiomatic way to create a list that I'm uncertain of what the
    end size will be and fill it with structs?

    I'm a bit lost as to what the best way to do this is, and I have a a
    feeling that "container/list" is a bit overkill.

    But also, having an empty array and then continuing to append one struct
    after another in my for loop seems to be not the best way either.

    Thoughts?
    I recommend you read http://golang.org/doc/effective_go.html and go through
    the tour at http://tour.golang.org
    They will answer your question.


    --
    =====================
    http://jessta.id.au

    --
    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 golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Carlos Castillo at Sep 2, 2013 at 4:19 am

    On Sunday, September 1, 2013 6:16:31 AM UTC-7, Daniel Alan Miller wrote:
    What is the idiomatic way to create a list that I'm uncertain of what the
    end size will be and fill it with structs?

    I'm a bit lost as to what the best way to do this is, and I have a a
    feeling that "container/list" is a bit overkill.

    But also, having an empty array and then continuing to append one struct
    after another in my for loop seems to be not the best way either.
    Try it out, seems simple enough... Might be as good as you need.

    Thoughts?
    --
    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 golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedSep 2, '13 at 1:46a
activeSep 2, '13 at 4:19a
posts3
users3
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase