Closed ichigozero closed 11 months ago
maybe https://github.com/labstack/echo/blob/e6b96f8873fed46e71e0d34cddb81c533167f954/middleware/util.go#L69 would be suitable here also.
maybe https://github.com/labstack/echo/blob/e6b96f8873fed46e71e0d34cddb81c533167f954/middleware/util.go#L69 would be suitable here also.
Thank you for the comment. I will take a look the link you mentioned and update the PR accordingly.
@aldas I have updated the source code as you suggested. Please let me know what you think.
@aldas Hi, just wondering what is the progress for this PR?
The current implementation for
random
package relied on globally seeded value. If any other part of the programs callrand.Seed
, the string generate byrandom
package will also be affected.To fix this issue, instead of callingrand.Seed
during initialization,NewSource
is called and the return value is stored insideRandom
struct.I made changes by referring to the source code from the link below. https://github.com/labstack/echo/blob/e6b96f8873fed46e71e0d34cddb81c533167f954/middleware/util.go#L69
I also did some benchmarks before and after the update.
Before
After (with sync.Mutex)
After (with sync.Pool)