FAQ
Can anyone give me some explanation about *string and string? I tried to
use go-toml-config but it gave me *string type instead of string. I can't
find any explanation in http://golang.org/pkg/strings/. Thanks before.


Best regards,
Boy Sandy G.A.

--
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/d/optout.

Search Discussions

  • Guillaume J. Charmes at Nov 20, 2014 at 6:08 pm
    Usually, *string is used to provide a distinction between `nil` and empty
    string. When the value is not set: the pointer to string is nil, when it is
    set, it might be empty string.

    --

    Guillaume J. Charmes
    about.me/guillaumecharmes
    [image: Guillaume J. Charmes on about.me]
       <http://about.me/guillaumecharmes>
    On Thu, Nov 20, 2014 at 5:36 AM, wrote:

    Can anyone give me some explanation about *string and string? I tried to
    use go-toml-config but it gave me *string type instead of string. I can't
    find any explanation in http://golang.org/pkg/strings/. Thanks before.


    Best regards,
    Boy Sandy G.A.

    --
    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/d/optout.
    --
    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/d/optout.
  • DV at Nov 20, 2014 at 11:26 pm
    It's the exact same difference as the difference between any type T and a
    pointer to T, or *T.
    int and *int
    float and *float
    string and *string
    map[string]string and *map[string]string
    etc.

    Use a pointer when you need a pointer and a value when you don't.
    On Thursday, November 20, 2014 3:36:12 AM UTC-7, reno....@gmail.com wrote:

    Can anyone give me some explanation about *string and string? I tried to
    use go-toml-config but it gave me *string type instead of string. I can't
    find any explanation in http://golang.org/pkg/strings/. Thanks before.


    Best regards,
    Boy Sandy G.A.
    --
    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/d/optout.
  • Reno Esper at Nov 21, 2014 at 12:38 am
    I see, so if I want to convert the *string into integer I should do it with
    *variable, am I right?
    Thank you very much for the responses. I appreciate it.


    Best regards,
    Boy Sandy G.A.
    On Friday, November 21, 2014 6:26:56 AM UTC+7, DV wrote:

    It's the exact same difference as the difference between any type T and a
    pointer to T, or *T.
    int and *int
    float and *float
    string and *string
    map[string]string and *map[string]string
    etc.

    Use a pointer when you need a pointer and a value when you don't.
    On Thursday, November 20, 2014 3:36:12 AM UTC-7, reno....@gmail.com wrote:

    Can anyone give me some explanation about *string and string? I tried to
    use go-toml-config but it gave me *string type instead of string. I can't
    find any explanation in http://golang.org/pkg/strings/. Thanks before.


    Best regards,
    Boy Sandy G.A.
    --
    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/d/optout.
  • Andrewchamberss at Nov 21, 2014 at 1:20 am
    *string means pointer to a string. string is just a string. string can
    either be empty, or not empty, sometimes people use *string to allow for
    the pointer to be nil meaning optional.

    Personally I don't think this is a good idea as it introduces null
    pointers, MaybeString struct might be better with String() and IsValid()
    methods.
    On Thursday, November 20, 2014 11:36:12 PM UTC+13, reno....@gmail.com wrote:

    Can anyone give me some explanation about *string and string? I tried to
    use go-toml-config but it gave me *string type instead of string. I can't
    find any explanation in http://golang.org/pkg/strings/. Thanks before.


    Best regards,
    Boy Sandy G.A.
    --
    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/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedNov 20, '14 at 6:05p
activeNov 21, '14 at 1:20a
posts5
users4
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase