From 3adb6c9c8e81277c17c86218901600e31ed63d1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Benkovsk=C3=BD?= Date: Wed, 12 Jul 2023 10:54:35 +0200 Subject: [PATCH] remove error return from constructor --- doq/client.go | 4 ++-- doq/client_test.go | 9 +++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/doq/client.go b/doq/client.go index e97877c..a9dfb60 100644 --- a/doq/client.go +++ b/doq/client.go @@ -34,7 +34,7 @@ type Options struct { } // NewClient creates a new doq.Client used for sending DoQ queries. -func NewClient(addr string, options Options) (*Client, error) { +func NewClient(addr string, options Options) *Client { client := Client{} client.addr = addr @@ -51,7 +51,7 @@ func NewClient(addr string, options Options) (*Client, error) { client.writeTimeout = options.WriteTimeout client.connectTimeout = options.ConnectTimeout - return &client, nil + return &client } func (c *Client) dial(ctx context.Context) error { diff --git a/doq/client_test.go b/doq/client_test.go index abd715a..966373a 100644 --- a/doq/client_test.go +++ b/doq/client_test.go @@ -85,8 +85,7 @@ func Test(t *testing.T) { server.start() defer server.stop() - client, err := NewClient(server.addr, Options{TLSConfig: generateTLSConfig()}) - require.NoError(t, err) + client := NewClient(server.addr, Options{TLSConfig: generateTLSConfig()}) msg := dns.Msg{} msg.SetQuestion("example.org.", dns.TypeA) @@ -103,8 +102,7 @@ func TestWriteTimeout(t *testing.T) { server.start() defer server.stop() - client, err := NewClient(server.addr, Options{TLSConfig: generateTLSConfig(), WriteTimeout: 1 * time.Nanosecond}) - require.NoError(t, err) + client := NewClient(server.addr, Options{TLSConfig: generateTLSConfig(), WriteTimeout: 1 * time.Nanosecond}) msg := dns.Msg{} msg.SetQuestion("example.org.", dns.TypeA) @@ -119,8 +117,7 @@ func TestReadTimeout(t *testing.T) { server.start() defer server.stop() - client, err := NewClient(server.addr, Options{TLSConfig: generateTLSConfig(), ReadTimeout: 1 * time.Nanosecond}) - require.NoError(t, err) + client := NewClient(server.addr, Options{TLSConfig: generateTLSConfig(), ReadTimeout: 1 * time.Nanosecond}) msg := dns.Msg{} msg.SetQuestion("example.org.", dns.TypeA)