Skip to content

Commit

Permalink
remove error return from constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
Tantalor93 committed Jul 12, 2023
1 parent 93b0030 commit 3adb6c9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
4 changes: 2 additions & 2 deletions doq/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down
9 changes: 3 additions & 6 deletions doq/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 3adb6c9

Please sign in to comment.