netlink/netlink_linux.go
func NetworkLinkDel(name string) error {
	if name == "" {
		return fmt.Errorf("Network link name can not be empty!")
	}

	s, err := getNetlinkSocket()
	if err != nil {
		return err
	}
	defer s.Close()

	iface, err := net.InterfaceByName(name)
	if err != nil {
		return err
	}

	wb := newNetlinkRequest(syscall.RTM_DELLINK, syscall.NLM_F_ACK)

	msg := newIfInfomsg(syscall.AF_UNSPEC)
	msg.Index = int32(iface.Index)
	wb.AddData(msg)

	if err := s.Send(wb); err != nil {
		return err
	}

	return s.HandleAck(wb.Seq)
}
func NetworkLinkDel(name string) error {
	if name == "" {
		return fmt.Errorf("Network link name can not be empty!")
	}

	s, err := getNetlinkSocket()
	if err != nil {
		return err
	}
	defer s.Close()

	iface, err := net.InterfaceByName(name)
	if err != nil {
		return err
	}

	wb := newNetlinkRequest(syscall.RTM_DELLINK, syscall.NLM_F_ACK)

	msg := newIfInfomsg(syscall.AF_UNSPEC)
	msg.Index = int32(iface.Index)
	wb.AddData(msg)

	if err := s.Send(wb); err != nil {
		return err
	}

	return s.HandleAck(wb.Seq)
}
func NetworkLinkDel ( name string ) error { if name == " " { return fmt . Errorf ( " " ) } s , err := getNetlinkSocket ( ) if err != nil { return err } defer s . Close ( ) iface , err := net . InterfaceByName ( name ) if err != nil { return err } wb := newNetlinkRequest ( syscall . RTM_DELLINK , syscall . NLM_F_ACK ) msg := newIfInfomsg ( syscall . AF_UNSPEC ) msg . Index = int32 ( iface . Index ) wb . AddData ( msg ) if err := s . Send ( wb ) ; err != nil { return err } return s . HandleAck ( wb . Seq ) }
// Delete a network link.
// This is identical to running: ip link del $name
Delete a network link . This is identical to running : ip link del $name