Am Montag, 26. September 2016 04:53:01 UTC+2 schrieb Jon Strauss: > > This error: > > panic: runtime error: invalid memory address or nil pointer dereference > > [signal 0xb code=0x1 addr=0x20 pc=0x401487] > > > goroutine 1 [running]: > > panic(0x50bfa0, 0xc82000a0c0) > > /usr/lib/go-1.6/src/runtime/panic.go:481 +0x3e6 > > main.main() > > /root/Whois3/rest-whois-threaded/main.go:65 +0x67 > > Is produced by this code: I commented line 65. Is there an error in the go? >
No. In is nil and calling Accept on nil panics. You really should check all errors. V. > package main > > > import ( > > "os" > > "net" > > "syscall" > > "time" > > ) > > > func reader(incoming net.Conn, outgoing net.Conn,ready chan bool) { > > > var buffer []byte > > <- ready > > buffer = make([]byte,2) > > for { > > read, _ := incoming.Read(buffer) > > outgoing.Write(buffer) > > if read == 0 { > > break > > } > > } > > return > > } > > > func writer(outgoing net.Conn, incoming net.Conn, ready chan bool) { > > > var buffer []byte > > <- ready > > buffer = make([]byte,2) > > for { > > read, _ := outgoing.Read(buffer) > > incoming.Write(buffer) > > if read == 0 { > > break > > } > > } > > return > > } > > > func worker(connection net.Conn) { > > var ready chan bool > > var app net.Conn > > var process *os.Process > > var attr *syscall.ProcAttr > > var stuff []string > > > attr.Dir = "/my/dir" > > > pid,_ := syscall.ForkExec("/my/exec", stuff, attr) > > process.Pid = pid > > app, _= net.Dial("tcp", "127.0.0.1:5000") > > go reader(connection,app,ready) > > go writer(connection,app,ready) > > > ready <- true > > time.Sleep(7 * time.Second) > > process.Kill() > > return > > } > > > func main() { > > ln, _ := net.Listen("tcp", ":80") > > > for { > > conn, _ := ln.Accept() // Line 65 > > go worker(conn) > > } > > > } > -- 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.