On Mon, Feb 26, 2018 at 10:01 PM, <k1atti...@gmail.com> wrote: > or similar simpler example : > > this works : > > var j int = 42 > var p *int > p=&j // this works > fmt.Println(*p) > > > > var j int = 42 > var p *int > p=&int(j) //this doesn't work > fmt.Println(*p) >
According to the spec, conversions are not addressable: https://golang.org/ref/spec#Address_operators > > > > > 2018. február 27., kedd 5:56:57 UTC+1 időpontban k1at...@gmail.com a > következőt írta: >> >> Hi >> >> I have seen this example somewhere but i modified it : >> >> package main >> >> import "fmt" >> >> type notifier interface { >> notify() >> } >> >> type duration int >> >> func (d *duration) notify() { >> fmt.Println("Sending Notification in", *d) >> } >> >> func main() { >> var n notifier >> var i int = 42 >> n = &duration(i) >> n.notify() >> } >> >> >> but i get the following error message : >> >> >> prog.go:17:6: cannot take the address of duration(i) >> >> >> >> Why ? i is a variable with address in memory (it works : >> >> var i int = 42 >> var p * int >> p=&i >> >> ) >> >> Thank you in advance Attila >> >> >> > -- > 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+unsubscr...@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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.