-
Notifications
You must be signed in to change notification settings - Fork 26
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
What happened?
Just reading some of the source code. Nice library!
Since go passes function arguments by value, the address returned by op.Ref is not the address of the original value, but of a copy of the original value. Also, op.Deref will result in a panic if a nil pointer is passed in, but this is expected.
What did you expect to happen?
I don't believe that such a Ref function can easily be written in go. The & operator should probably be used instead.
Which version of go-functional were you using?
v2.5.0
To Reproduce
v := 0
var p *int
fmt.Printf("address of v %v\n", &v)
r := Ref(v)
fmt.Printf("Ref of v %v\n", r)
d := Deref(p)
fmt.Printf("Defef of p %v\n", d)
As expected, the two printed addresses are not the same and the Deref of a nil pointer results in a panic.
Do you intend to fix this issue yourself?
No.
Additional context
Perhaps I've mistaken the original intent.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working