From 2ace07d2d88c01a56b4d0f3194bd74a518a769c8 Mon Sep 17 00:00:00 2001 From: Keuin Date: Fri, 14 Jul 2023 22:25:27 +0800 Subject: Refactor: use pointer type of `Bilibili` to prevent unexpected copy. --- bilibili/client.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'bilibili/client.go') diff --git a/bilibili/client.go b/bilibili/client.go index 35d06e4..17a42d6 100644 --- a/bilibili/client.go +++ b/bilibili/client.go @@ -26,7 +26,7 @@ type Bilibili struct { logger logging.Logger } -func NewBilibiliWithContext(ctx context.Context, netTypes []types.IpNetType, logger logging.Logger) Bilibili { +func NewBilibiliWithContext(ctx context.Context, netTypes []types.IpNetType, logger logging.Logger) *Bilibili { var nets []types.IpNetType nets = append(nets, netTypes...) if len(nets) == 0 { @@ -39,7 +39,7 @@ func NewBilibiliWithContext(ctx context.Context, netTypes []types.IpNetType, log transport.DialTLSContext = nil transport.DialContext, _ = np.NextNetworkType(dialer) - return Bilibili{ + return &Bilibili{ logger: logger, userAgent: kUserAgent, http: http.DefaultClient, @@ -48,11 +48,11 @@ func NewBilibiliWithContext(ctx context.Context, netTypes []types.IpNetType, log } } -func NewBilibiliWithNetType(netTypes []types.IpNetType, logger logging.Logger) Bilibili { +func NewBilibiliWithNetType(netTypes []types.IpNetType, logger logging.Logger) *Bilibili { ctx := context.Background() return NewBilibiliWithContext(ctx, netTypes, logger) } -func NewBilibili(logger logging.Logger) Bilibili { +func NewBilibili(logger logging.Logger) *Bilibili { return NewBilibiliWithNetType(nil, logger) } -- cgit v1.2.3