func checkPermissions() error {
	if uid := os.Getuid(); uid == 0 {
		return nil
	}
	c := cap.GetProc()
	var err error
	capabilities := []cap.Value{
		cap.NET_ADMIN,  
	}
	for _, capability := range capabilities {
		err = checkCapability(c, capability)
		if err != nil {
			break
		}
	}
	if err == nil {
		return nil
	}
	return fmt.Errorf("gof5 needs to run with CAP_NET_ADMIN capability or as root: %v", err)
}
TODO: detect cap_net_bind_service for DNS bind
package main
import (
	"fmt"
	"os"
	"strings"
	"kernel.org/pub/linux/libs/security/libcap/cap"
)
func checkCapability(c *cap.Set, capability cap.Value) error {
	capable, err := c.GetFlag(cap.Effective, capability)
	if err != nil {
		return fmt.Errorf("failed to get process effective capability flag: %v", err)
	}
	if capable {
		return nil
	}
	capable, err = c.GetFlag(cap.Permitted, capability)
	if err != nil {
		return fmt.Errorf("failed to get process permitted capability flag: %v", err)
	}
	if capable {
		if err = c.SetFlag(cap.Effective, true, capability); err != nil {
			return fmt.Errorf("permitted capability detected: failed to set effective %s capability flag: %v", strings.ToUpper(capability.String()), err)
		}
		if err = c.SetProc(); err != nil {
			return fmt.Errorf("permitted capability detected: failed to set effective %s capability: %v", strings.ToUpper(capability.String()), err)
		}
		return nil
	}
	return fmt.Errorf("cannot obtain effective %s capability", strings.ToUpper(capability.String()))
}