Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
陈曦
sub2api
Commits
372a0129
Commit
372a0129
authored
Dec 24, 2025
by
ianshaw
Browse files
fix(backend): handle defer Close() errors in crs_sync_service
修复 golangci-lint 错误检查问题 - 使用匿名函数包装 defer Close() 并忽略错误 - 符合 Go 最佳实践
parent
8b163ca4
Changes
1
Show whitespace changes
Inline
Side-by-side
backend/internal/service/crs_sync_service.go
View file @
372a0129
...
@@ -783,7 +783,7 @@ func crsLogin(ctx context.Context, client *http.Client, baseURL, username, passw
...
@@ -783,7 +783,7 @@ func crsLogin(ctx context.Context, client *http.Client, baseURL, username, passw
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
err
return
""
,
err
}
}
defer
resp
.
Body
.
Close
()
defer
func
()
{
_
=
resp
.
Body
.
Close
()
}()
raw
,
_
:=
io
.
ReadAll
(
io
.
LimitReader
(
resp
.
Body
,
1
<<
20
))
raw
,
_
:=
io
.
ReadAll
(
io
.
LimitReader
(
resp
.
Body
,
1
<<
20
))
if
resp
.
StatusCode
<
200
||
resp
.
StatusCode
>=
300
{
if
resp
.
StatusCode
<
200
||
resp
.
StatusCode
>=
300
{
...
@@ -818,7 +818,7 @@ func crsExportAccounts(ctx context.Context, client *http.Client, baseURL, adminT
...
@@ -818,7 +818,7 @@ func crsExportAccounts(ctx context.Context, client *http.Client, baseURL, adminT
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
defer
resp
.
Body
.
Close
()
defer
func
()
{
_
=
resp
.
Body
.
Close
()
}()
raw
,
_
:=
io
.
ReadAll
(
io
.
LimitReader
(
resp
.
Body
,
5
<<
20
))
raw
,
_
:=
io
.
ReadAll
(
io
.
LimitReader
(
resp
.
Body
,
5
<<
20
))
if
resp
.
StatusCode
<
200
||
resp
.
StatusCode
>=
300
{
if
resp
.
StatusCode
<
200
||
resp
.
StatusCode
>=
300
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment