Paramita
Home
Blog
Moment
Snippet
About
代码笔记
Categories
Blog (42)
Featured Tags
alpinejs (2)
ant-design (5)
antd (1)
aspose (1)
aws (1)
cloudflare (1)
dva (2)
echo (2)
filamentphp (1)
gin (1)
git (1)
github (2)
go-mecab (1)
golang (15)
goquery (1)
grpc (1)
japanese (1)
java (1)
lambda (1)
laravel (8)
leetcode (5)
less (1)
linux (3)
livewirejs (1)
mac (1)
mysql (2)
nestjs (1)
nginx (1)
nodejs (1)
npm (1)
php (5)
popclip (1)
ppt (1)
r2 (1)
react (3)
reactjs (9)
remixicon (1)
s3 (1)
shell (2)
tailwindcss (2)
taro (3)
tarojs (1)
telescope (2)
typeorm (1)
umi (1)
umijs (3)
workers (1)
zustand (2)
免签 (1)
小程序 (4)
支付宝 (1)
Blog
42 posts
Blog
is the place to record my codinglife.
««
«
5
6
7
8
9
»
»»
golang实现laravel的cache remember方法
Dec 27, 2022
One minute read
怀念laravel的缓存,太方便了,用golang实现一下 安利一下这个包 gookit/cache type Cache interface { // basic operation Has(key string) bool Get(key string) interface{} Set(key string, val interface{}, ttl time.Duration) (err error) Del(key string) error // multi operation GetMulti(keys []string) map[string]interface{} SetMulti(values map[string]interface{}, ttl time.Duration) (err error) DelMulti(keys []string) error // clear and close Clear() error Close() error } 这个包通过适配各种常用的缓存驱动来提供统一的封装好的缓存操作方法。切换驱动只需要一行代码就行。 func Remember(ctx context.Context, pointer interface{}, key string, ttl time.Duration, cb func() error) error { if cache.Has(key) { //如果缓存有值,则反序列化 return Json.Unmarshal(cache.Get(key).([]byte), pointer) } else { //如果没有值,调用callback, err := cb() if err != nil { return err } /......
blog
golang
laravel
Echo获取代理真实Ip
Dec 19, 2022
One minute read
后端用的echo,前面分别挂了一台上海和香港的服务器做代理转发,反向代理之后获取不到真实IP _, n1, _ := net.ParseCIDR("110.42.x.x/32") //解析cidr拿到ipnet _, n2, _ := net.ParseCIDR("119.28.x.x/32") E.IPExtractor = echo.ExtractIPFromXFFHeader(echo.TrustIPRange(n1),echo.TrustIPRange(n2)) //设置代理的ip......
blog
golang
echo
javassist修改jar包
Dec 4, 2022
3 minutes read
用aspose slide为ppt文件生成预览图片,生成图片有水印,可以用javassist修改jar包的方式来去除水印限制 pom文件 <dependency> <groupId>com.aspose</groupId> <artifactId>aspose-slides</artifactId> <version>22.9</version> <scope>system</scope> <systemPath>${project.basedir}/src/main/resources/lib/aspose-slides-22.9-jdk16.jar </systemPath> <classifier>jdk16</classifier> </dependency> <dependency> <groupId>org.javassist</groupId> <artifactId>javassist</artifactId> <version>3.28.0-GA</version> </dependency> 填个错的license试试 String license = "<License>\n" + " <Data>\n" + " <Products>\n" + " <Product>Aspose.Total for Java</Product>\n" + " <Product>Aspose.Words for Java</Product>\n" + " </Products>\n" + " <EditionType>Enterprise</EditionType>\n" + " <SubscriptionExpiry>20991231</SubscriptionExpiry>\n" + " <LicenseExpiry>20991231</LicenseExpiry>\n" + " <SerialNumber>8bfe198c-7f0c-4ef8-8ff0-</SerialNumber>\n" + " </Data>\n" + "</License>"; InputStream is = new ByteArrayInputStream(license.getBytes(StandardCharsets.UTF_8)); License aposeLic = new License(); aposeLic.setLicense(is); 看看报错信息 2022-12-04 03:03:45.498 ERROR 63412 --- [nio-8091-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is class com.aspose.slides.exceptions.InvalidOperationException: License parsing error ---> class com.aspose.slides.exceptions.InvalidOperationException: Signature check error. ---> java.security.SignatureException: Signature length not correct: got 0 but was expecting 256 --- End......
blog
java