Standard library / net
net.Interface.MulticastAddrs()
List multicast groups joined on the interface. An empty successful result is valid; this Linux fixture checks enumeration, not membership or delivery. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
func (ifi *Interface) MulticastAddrs() ([]Addr, error)Return Value
([]Addr, error)
Operation result; check errors and validity indicators when returned.
Working Example
Example Snippetgo
package main
import ( "fmt" "net")
func main() { all := must(net.Interfaces()) var loop net.Interface for _, x := range all { if x.Flags&net.FlagLoopback != 0 { loop = x break } } if loop.Index == 0 { panic("no loopback interface") } _, e := loop.MulticastAddrs() fmt.Println(e == nil)}
func must[T any](v T, e error) T { if e != nil { panic(e) } return v}func check(e error) { if e != nil { panic(e) }}