Skip to content

Instantly share code, notes, and snippets.

@suzuken suzuken/a.go

Created Oct 6, 2016
Embed
What would you like to do?
package main
import (
"bufio"
"flag"
"fmt"
"log"
"net"
"os"
"strings"
)
func main() {
if err := realmain(); err != nil {
log.Fatalf("err: %s", err)
}
}
func realmain() error {
var (
filename = flag.String("filename", "", "ip.txt")
)
flag.Parse()
f, err := os.Open(*filename)
if err != nil {
return err
}
defer f.Close()
scanner := bufio.NewScanner(f)
for scanner.Scan() {
ip := scanner.Text()
s, err := net.LookupAddr(ip)
if err != nil {
return err
}
fmt.Printf("%s\t%s\n", ip, strings.Join(s, ","))
}
return scanner.Err()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.