Trig,
I'm very curious why you want to use a pointer to a string? Since strings
are immutable, and already are like "pointers" internally, I have rarely,
if ever, used *string in go. What is it that you achieve by doing this?
- Jake
On Wednesday, June 3, 2020 at 10:33:31 PM UTC-4, Trig wrote:
>
> I posted this question the other day and don't see it (may have posted
> from another gmail account and it's still pending approval)... so here I am
> again.
>
> Let's say I have something like below:
> type (
> Person struct {
> FirstName *string
> }
> )
>
> Usually, I see something like the following when assigning:
> fn := "John"
> _ = Person{
> FirstName: &fn,
> }
>
> Would something like the following be alright and acceptable practice:
> _ = Person{
> FirstName: pString("John")
> }
>
>
> func pString(content string) *string {
> return &content
> }
>
>
--
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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/37e1379c-9f03-4107-b7a2-375060d10cdb%40googlegroups.com.