Last active
August 23, 2016 23:36
-
-
Save jasonkeene/ea9d9a63b3c15763adfdd03895245dac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"net" | |
"os" | |
) | |
const sock = "/tmp/test.sock" | |
func main() { | |
os.Remove(sock) | |
l, err := net.Listen("unix", sock) | |
if err != nil { | |
panic(err) | |
} | |
go func() { | |
c, err := net.Dial("unix", sock) | |
if err != nil { | |
panic(err) | |
} | |
c.Close() | |
}() | |
r, err := l.Accept() | |
if err != nil { | |
panic(err) | |
} | |
// if you give Read a nil byte slice it will not return an error | |
var b []byte | |
// if you give Read a non-nil byte slice you get io.EOF | |
//b := make([]byte, 1024) | |
_, err = r.Read(b) | |
if err == nil { | |
println("failed") | |
return | |
} | |
println("passed, err was:", err.Error()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment