this is my code:
package main
import ("fmt")
type Message struct {
Text []byte
Tag string
}
func main() {
var m Message
pkt := []byte("Hey")
editMessage(&m, &pkt)
fmt.Println(string(m.Text))
}
func editMessage(m *Message, pkt *[]byte) {
m.Text = *pkt
}
And I get "Hey" as expected on the output.
If I change m.Text = *pkt
with (*m).Text = *pkt
It works as well!
Which is the correct/more efficient version? Or is it just a shortcut?
This thing doesn't now work all the time, if I use
c *net.Conn
as input in a function, I must use
something := (*c).RemoteAddr()
to get it working.
Thank you