Debian Codegraph @

_test/issue-1330.go

raw symbols SCIP
1 package main
2
3 import (
4 "fmt"
5 "io"
6 "net"
7 )
8
9 type wrappedConn struct {
10 net.Conn
11 }
12
13 func main() {
14 _, err := net.Listen("tcp", "127.0.0.1:49153")
15 if err != nil {
16 panic(err)
17 }
18
19 dialer := &net.Dialer{
20 LocalAddr: &net.TCPAddr{
21 IP: net.ParseIP("127.0.0.1"),
22 Port: 0,
23 },
24 }
25
26 conn, err := dialer.Dial("tcp", "127.0.0.1:49153")
27 if err != nil {
28 panic(err)
29 }
30 defer conn.Close()
31
32 t := &wrappedConn{conn}
33 var w io.Writer = t
34 if n, err := w.Write([]byte("hello")); err != nil {
35 fmt.Println(err)
36 } else {
37 fmt.Println(n)
38 }
39 }
40
41 // Output:
42 // 5