Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
黄成意
/
go_sku_server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
87f3eca1
authored
Oct 26, 2025
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
不要复用ctx
parent
840cd331
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
3 deletions
controller/sku_controller.go
controller/sku_controller.go
View file @
87f3eca1
...
...
@@ -75,10 +75,13 @@ func CommonController(ctx *gin.Context) map[string]interface{} {
idsToProcess
:=
make
([]
string
,
len
(
zyGoodsId
))
copy
(
idsToProcess
,
zyGoodsId
)
// 在启动协程前,复制一份 context
ctxCopy
:=
ctx
.
Copy
()
go
func
(
ctx_in
*
gin
.
Context
,
goodsIds_in
[]
string
,
chs_in
chan
sync
.
Map
)
{
defer
wg
.
Done
()
zyService
.
ZyGoodsDetail
(
ctx_in
,
goodsIds_in
,
chs_in
)
}(
ctx
,
idsToProcess
,
ch
)
}(
ctx
Copy
,
idsToProcess
,
ch
)
zyGoodsId
=
zyGoodsId
[
:
0
]
}
...
...
@@ -91,10 +94,13 @@ func CommonController(ctx *gin.Context) map[string]interface{} {
idsToProcess
:=
make
([]
string
,
len
(
lyGoodsId
))
copy
(
idsToProcess
,
lyGoodsId
)
// 在启动协程前,复制一份 context
ctxCopy
:=
ctx
.
Copy
()
go
func
(
ctx_in
*
gin
.
Context
,
goodsIds_in
[]
string
,
chs_in
chan
sync
.
Map
)
{
defer
wg
.
Done
()
lyService
.
LyGoodsDetail
(
ctx_in
,
goodsIds_in
,
chs_in
)
}(
ctx
,
idsToProcess
,
ch
)
}(
ctx
Copy
,
idsToProcess
,
ch
)
lyGoodsId
=
lyGoodsId
[
:
0
]
}
...
...
@@ -121,10 +127,13 @@ func CommonController(ctx *gin.Context) map[string]interface{} {
idsToProcess
:=
make
([]
string
,
len
(
lyGoodsId
))
copy
(
idsToProcess
,
lyGoodsId
)
// 在启动协程前,复制一份 context
ctxCopy
:=
ctx
.
Copy
()
go
func
(
ctx_in
*
gin
.
Context
,
goodsIds_in
[]
string
,
chs_in
chan
sync
.
Map
)
{
defer
wg
.
Done
()
lyService
.
LyGoodsDetail
(
ctx_in
,
goodsIds_in
,
chs_in
)
}(
ctx
,
idsToProcess
,
ch
)
}(
ctx
Copy
,
idsToProcess
,
ch
)
}
// 开启一个协程,等待所有任务完成,然后关闭channel
...
...
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