func connect(ip string, the_ports *[]string) {
	for _, port := range *the_ports {
		if debug {
			fmt.Fprintln(os.Stderr, port)
		}
		hostPort := net.JoinHostPort(ip, port)
		conn, err := net.DialTimeout("tcp", hostPort, connection_timeout)
		if err != nil {
			if debug {
				fmt.Printf("1,%s\n", err.Error())
			}
		} else {
			fmt.Printf("%s,%s,%s 00:00:00,%t\n", ip, port, date_string, remote)
			conn.Close()
		}
	}
	defer wg.Done()
	<-sem
}
connect
Take an IP string and a ptr to the ports slice
package main
import "bufio"
import "fmt"
import "log"
import "net"
import "os"
import "sync"
import "time"
var date = time.Now()
var date_string = date.Format("2006-01-02")
var remote = false
var ips []string
var ports []string
var debug bool = false
var wg sync.WaitGroup
var sem = make(chan struct{}, 32768)
const usage string = "usage: ./netscan ips.txt ports.txt > results.txt"
const connection_timeout = 2 * time.Second