Skip to content

adding support for quick pointer conversion #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 1, 2024

Conversation

0syntrax0
Copy link
Contributor

@0syntrax0 0syntrax0 commented Oct 21, 2024

Adding support for quick pointer conversion.
This is much more helpful when setting up structs with pointer fields.

So that instead of:

v := "value"
MyPointerVar = &v

// or

v1 := "value1"
v2 := 100
v3 := []string{}
obj := Obj {
  Field1: &v1,
  Field2: &v2,
  Field3: &v3,
}

We just use:
MyPointerVar = u.ToPointer("value")

obj := Obj {
  Field1: u.ToPointer("value"),
  Field2: u.ToPointer(100),
  Field3: u.ToPointer([]string{}),
}

@rjNemo rjNemo self-requested a review November 1, 2024 09:19
@rjNemo rjNemo merged commit fbbd039 into rjNemo:main Nov 1, 2024
1 check failed
@rjNemo
Copy link
Owner

rjNemo commented Nov 1, 2024

In the first place, I had doubts about this PR, but it can be useful.

@0syntrax0 Thank you for the contribution 🦾

@0syntrax0 0syntrax0 deleted the pointer_support branch November 11, 2024 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants