diff options
author | Keuin <[email protected]> | 2023-07-14 22:25:27 +0800 |
---|---|---|
committer | Keuin <[email protected]> | 2023-07-14 22:25:27 +0800 |
commit | 2ace07d2d88c01a56b4d0f3194bd74a518a769c8 (patch) | |
tree | b218043dacec97c08469855950838ceca67496c6 /bilibili/client.go | |
parent | d7bd3edf61109936a09a5115938e86b1c17ea024 (diff) |
Refactor: use pointer type of `Bilibili` to prevent unexpected copy.
Diffstat (limited to 'bilibili/client.go')
-rw-r--r-- | bilibili/client.go | 8 |
1 files changed, 4 insertions, 4 deletions
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) } |