func (s *Scan) Run() {
	var (
		openPorts []int
		err       error
	)
	if s.minPort != s.maxPort {
		fmt.Printf("Scan %s (%s) TCP ports %d-%d\n", s.target, s.raddr, s.minPort, s.maxPort)
	} else {
		fmt.Printf("Scan %s (%s) TCP port %d\n", s.target, s.raddr, s.minPort)
	}
	table := tablewriter.NewWriter(os.Stdout)
	table.SetHeader([]string{"Protocol", "Port", "Status"})
	tStart := time.Now()
	if s.connScan {
		openPorts = s.tcpConnScan()
	} else {
		openPorts, err = s.tcpSYNScan()
	}
	if err != nil {
		println(err.Error())
		return
	}
	for _, p := range openPorts {
		table.Append([]string{"TCP", fmt.Sprintf("%d", p), "Open"})
	}
	if len(openPorts) == 0 {
		println("there isn't any opened port")
	} else {
		println("")
		table.Render()
		elapsed := fmt.Sprintf("%.3f seconds", time.Since(tStart).Seconds())
		println("Scan done:", len(openPorts), "opened port(s) found in", elapsed)
	}
}
Run tries to scan wide range ports (TCP)
package scan
import (
	"context"
	"fmt"
	"math/rand"
	"net"
	"os"
	"regexp"
	"sort"
	"strconv"
	"strings"
	"sync"
	"time"
	"github.com/google/gopacket"
	"github.com/google/gopacket/layers"
	"github.com/google/gopacket/pcap"
	"github.com/mehrdadrad/mylg/cli"
	"github.com/olekukonko/tablewriter"
)
type Scan struct {
	minPort  int
	maxPort  int
	target   string
	lport    int
	rport    int
	laddr    net.IP
	raddr    net.IP
	ifName   string
	network  string
	forceV4  bool
	forceV6  bool
	connScan bool
	ip       gopacket.NetworkLayer
}
func NewScan(args string, cfg cli.Config) (Scan, error) {
	var (
		scan Scan
		flag map[string]interface{}
		err  error
	)
	args, flag = cli.Flag(args)
	if _, ok := flag["help"]; ok || args == "" {
		help(cfg)
		return scan, fmt.Errorf("")
	}
	scan.forceV4 = cli.SetFlag(flag, "4", false).(bool)
	scan.forceV6 = cli.SetFlag(flag, "6", false).(bool)
	scan.connScan = cli.SetFlag(flag, "c", false).(bool)
	pRange := cli.SetFlag(flag, "p", cfg.Scan.Port).(string)
	re := regexp.MustCompile(`(\d+)(\-{0,1}(\d*))`)
	f := re.FindStringSubmatch(pRange)
	if len(f) != 4 {
		return scan, fmt.Errorf("error! please try scan help")
	}
	scan.target = args
	if len(f) == 4 && f[2] != "" {
		scan.minPort, err = strconv.Atoi(f[1])
		scan.maxPort, err = strconv.Atoi(f[3])
	} else {
		scan.minPort, err = strconv.Atoi(f[1])
		scan.maxPort, err = strconv.Atoi(f[1])
	}
	if err != nil {
		return scan, err
	}
	if scan.IsCIDR() {
		return scan, fmt.Errorf("it doesn't support CIDR")
	}
	scan.setIP()
	return scan, nil
}
func (s *Scan) IsCIDR() bool {
	_, _, err := net.ParseCIDR(s.target)
	if err != nil {
		return false
	}
	return true
}
func isIPv4(ip net.IP) bool {
	return len(ip.To4()) == net.IPv4len
}
func isIPv6(ip net.IP) bool {
	if r := strings.Index(ip.String(), ":"); r != -1 {
		return true
	}
	return false
}
func (s *Scan) setIP() error {
	ips, err := net.LookupIP(s.target)
	if err != nil {
		return err
	}
	for _, ip := range ips {
		if isIPv4(ip) && !s.forceV6 {
			s.raddr = ip
			s.network = "ip4"
			break
		} else if isIPv6(ip) && !s.forceV4 {
			s.raddr = ip
			s.network = "ip6"
			break
		}
	}
	return nil
}