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
0338c83b
Commit
0338c83b
authored
Dec 20, 2025
by
Forest
Browse files
ci(backend): 添加 errcheck 配置
parent
c6b3de11
Changes
3
Hide whitespace changes
Inline
Side-by-side
backend/.golangci.yml
View file @
0338c83b
...
@@ -21,6 +21,34 @@ linters:
...
@@ -21,6 +21,34 @@ linters:
deny
:
deny
:
-
pkg
:
sub2api/internal/repository
-
pkg
:
sub2api/internal/repository
desc
:
"
service
must
not
import
repository"
desc
:
"
service
must
not
import
repository"
errcheck
:
# Report about not checking of errors in type assertions: `a := b.(MyStruct)`.
# Such cases aren't reported by default.
# Default: false
check-type-assertions
:
true
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`.
# Such cases aren't reported by default.
# Default: false
check-blank
:
false
# To disable the errcheck built-in exclude list.
# See `-excludeonly` option in https://github.com/kisielk/errcheck#excluding-functions for details.
# Default: false
disable-default-exclusions
:
true
# List of functions to exclude from checking, where each entry is a single function to exclude.
# See https://github.com/kisielk/errcheck#excluding-functions for details.
exclude-functions
:
-
io/ioutil.ReadFile
-
io.Copy(*bytes.Buffer)
-
io.Copy(os.Stdout)
-
fmt.Println
-
fmt.Print
-
fmt.Printf
-
fmt.Fprint
-
fmt.Fprintf
-
fmt.Fprintln
# Display function signature instead of selector.
# Default: false
verbose
:
true
formatters
:
formatters
:
enable
:
enable
:
...
...
backend/internal/repository/claude_usage_service.go
View file @
0338c83b
...
@@ -19,7 +19,11 @@ func NewClaudeUsageFetcher() service.ClaudeUsageFetcher {
...
@@ -19,7 +19,11 @@ func NewClaudeUsageFetcher() service.ClaudeUsageFetcher {
}
}
func
(
s
*
claudeUsageService
)
FetchUsage
(
ctx
context
.
Context
,
accessToken
,
proxyURL
string
)
(
*
service
.
ClaudeUsageResponse
,
error
)
{
func
(
s
*
claudeUsageService
)
FetchUsage
(
ctx
context
.
Context
,
accessToken
,
proxyURL
string
)
(
*
service
.
ClaudeUsageResponse
,
error
)
{
transport
:=
http
.
DefaultTransport
.
(
*
http
.
Transport
)
.
Clone
()
transport
,
ok
:=
http
.
DefaultTransport
.
(
*
http
.
Transport
)
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"failed to get default transport"
)
}
transport
=
transport
.
Clone
()
if
proxyURL
!=
""
{
if
proxyURL
!=
""
{
if
parsedURL
,
err
:=
url
.
Parse
(
proxyURL
);
err
==
nil
{
if
parsedURL
,
err
:=
url
.
Parse
(
proxyURL
);
err
==
nil
{
transport
.
Proxy
=
http
.
ProxyURL
(
parsedURL
)
transport
.
Proxy
=
http
.
ProxyURL
(
parsedURL
)
...
...
backend/internal/service/account_usage_service.go
View file @
0338c83b
...
@@ -98,8 +98,10 @@ func (s *AccountUsageService) GetUsage(ctx context.Context, accountID int64) (*U
...
@@ -98,8 +98,10 @@ func (s *AccountUsageService) GetUsage(ctx context.Context, accountID int64) (*U
if
account
.
CanGetUsage
()
{
if
account
.
CanGetUsage
()
{
// 检查缓存
// 检查缓存
if
cached
,
ok
:=
usageCacheMap
.
Load
(
accountID
);
ok
{
if
cached
,
ok
:=
usageCacheMap
.
Load
(
accountID
);
ok
{
cache
:=
cached
.
(
*
usageCache
)
cache
,
ok
:=
cached
.
(
*
usageCache
)
if
time
.
Since
(
cache
.
timestamp
)
<
cacheTTL
{
if
!
ok
{
usageCacheMap
.
Delete
(
accountID
)
}
else
if
time
.
Since
(
cache
.
timestamp
)
<
cacheTTL
{
return
cache
.
data
,
nil
return
cache
.
data
,
nil
}
}
}
}
...
...
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