чт, 16 мая 2019 г. в 19:04, <jake6...@gmail.com>: > > > > On Wednesday, May 15, 2019 at 5:00:26 PM UTC-4, Vasiliy Tolstov wrote: >> >> Hi! I have error from net.InterfaceAddrs() like route ip+net: no such >> network interface >> i think that error happened because i have docker running that >> creates/deletes interfaces in my system. >> My question is - does returned slice from InterfaceAddrs filed always, >> or in case of error in always nil? As i understand go uses netlink to >> get all interfaces and when tries to get address from interface that >> already gone, this error happened. >> In my case this error not fatal, i only need to know all local unicast >> addresses. So if some interface is gone - this is not fatal, but i >> need to get all available ip. >> So if this function not fills the slice , i need to use different >> method to get all addresses. >> >> Can you helps me? >> P.S. Error not easy to reproduce in my case, so i can't easy check >> does InterfaceAddrs slice filled in case of error. >> > > > In Go it is customary that nothing should be assumed about the other return > values when there is an error. Since the InterfaceAddrs documentation does > not specify what the Addr slice contains on error, you should make no > assumptions. > > That said, looking at the code, it looks like most or all of the error paths > will return a nil slice. > > However, the InterfaceAddrs documentation does suggest an alternative. It > says: "use Interfaces and Interface.Addrs for more detail." So you could try > using that, and ignore any interfaces that return an error. > > -- > 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. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/c8580226-56ba-4647-b4d2-4948498f9755%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout.
Yes, thanks. This helps me. -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACaajQtpgo5o4wGmzMg18E%2BXRWPBs2M3n6W-7DOMdDjUyJxvTQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.