I am trying to write a port scanner in Go, i am facing few problems since i am new to this. Below is the code i have written till now.
package main
import (
    "fmt"
    "log"
    "net"
    "os"
)
func main() {
    callme()
}
func callme() {
    var status string
    getip := os.Args[1]
    getport := 0
    for i := 0; i < 10; i++ {
        getport += i
        data := getip + ":" + getport
        conn, err := net.Dial("tcp", data)
        if err != nil {
            log.Println("Connection error:", err)
            status = "Unreachable"
        } else {
            status = getport + " - " + "Open"
            defer conn.Close()
        }
        fmt.Println(status)
    }
}
I take ip from user as a command line arg, and then want to scan all ports on this ip. Since the net.Dial function needs data in a format like "ip:port" i am kinda confused how to concat string and int each time. Can any1 help me achieve this ?
 
     
    