Skip to content

Instantly share code, notes, and snippets.

@darraghenright
Created September 16, 2013 16:31
Show Gist options
  • Save darraghenright/6583029 to your computer and use it in GitHub Desktop.
Save darraghenright/6583029 to your computer and use it in GitHub Desktop.
wip
package main
import (
"bufio"
"fmt"
"log"
"net"
"strings"
)
func main() {
url := "cainteach"
conn, err := net.Dial("tcp", "ie.whois-servers.net:43")
if err != nil {
fmt.Println(err)
}
fmt.Fprintf(conn, "%s.ie / HTTP/1.0\r\n\r\n", url)
scanner := bufio.NewScanner(conn)
for scanner.Scan() {
// no to empty strings
// no to string starting with %
// all other strings split on : and key/value paired
line := scanner.Text()
if len(line) > 0 && line[0] != 37 {
fields := strings.Fields(line) // k,v split
fmt.Println(fields)
}
}
if err := scanner.Err(); err != nil {
log.Fatal(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment