I've modified the function accordingly:

func sock() {
  conn, err := net.Dial("tcp", "192.168.0.1:9991")
  if err != nil {
    fmt.Printf("\nDial has an error for you %v", err)
  }

  fmt.Fprintf(conn, "GET / HTTP/1.0\r\n\r\n")
  status, err := bufio.NewReader(conn).ReadString('\n')
  fmt.Printf("%v",status)
}

Nevertheless same issue appearing:
Dial has an error for you: dial tcp 192.168.0.1:9991: getsockopt: 
connection refusedpanic: runtime error: invalid memory address or nil 
pointer dereference 
[signal 0xb code=0x1 addr=0x20 pc=0x4612dc]
 

"Connection refused" is simple socket state, how can it call a panic?

Here is my go version:
$ go version  
go version go1.6.3 linux/amd64Enter code here...


-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to