package main import ( "bytes" "context" "crypto/tls" "log" "net/http" "time" "github.com/quic-go/quic-go" ) func main() { tlsConfig := &tls.Config{ InsecureSkipVerify: true, // testing only NextProtos: []string{"h3", "http/1.1"}, } url := "localhost:8080" req, _ := http.NewRequest("GET", url, nil) var buf bytes.Buffer req.Write(&buf) requestBytes := buf.Bytes() ctx := context.Background() connection, err := quic.DialAddr(ctx, url, tlsConfig, nil) if err != nil { println(err.Error()) return } ctx, cancel := context.WithTimeout(ctx, 5*time.Second) defer cancel() stream, err := connection.OpenUniStreamSync(ctx) if err != nil { log.Fatal(err) return } n, err := stream.Write(requestBytes) if err != nil { log.Fatal(err) } if err = stream.Close(); err != nil { log.Fatal(err) } println("ok") println(n) }