We think that growing up is a terrible thing because we haven't become the person we want to be. We are fortunate, yet lonely. We discover that the world is far broader than we imagined, yet we can't find a path that suits us; we find that the ways people conn…

2022年6月2日 0条评论 708点热度 2人点赞 痴者工良 阅读全文

我们之所以觉得成长是一件糟糕的事,是因为我们没有变成自己喜欢的样子。 我们是幸运的,却也是孤独的。我们发现世界远比自己想象的宽广,却又找不到适合自己的路;我们发现人与人之间认识的方式越来越多样,可能走进心里的人却越来越少;我们发现自己已经到了儿时羡慕的年纪,却没变成儿时羡慕的那种人。 然而,我们只能选择向前走。即使迷茫,也得往前走。我们碰壁,我们跌倒,我们迷茫,然后爬起来继续往前走。在很长一段时间内,因为突如其来的孤独感,和朋友之间越来越少的联系,我开始觉得自己是孤身一人。 我们都在逐渐失去中得到一些,在不停跌倒中…

2022年6月2日 0条评论 2614点热度 2人点赞 痴者工良 阅读全文

Basics There are three types of forms in Go Web: r.Form r.PostForm r.MultipartForm PostForm supports form-data and x-www-form-urlencoded request bodies, but does not support file uploads. MultipartForm only supports form-data request bodies, but supports file …

2022年5月29日 1条评论 4237点热度 1人点赞 痴者工良 阅读全文

基础 Go Web 的表单类型有三种: r.Form r.PostForm r.MultipartForm PostForm 支持 form-data 和 x-www-form-urlencoded 两种请求体,但是不支持上传文件。 MultipartForm 只支持 form-data 请求体,但是支持上传文件。 Form 包含了 URL Query 和 PostForm 两者的集合。 解析方式有两种: r.ParseForm() r.ParseMultipartForm(1 << 20) // 1&…

2022年5月29日 1条评论 4500点热度 1人点赞 痴者工良 阅读全文

小肥橘 [......] 继续阅读

2022年5月28日 2条评论 3210点热度 0人点赞 痴者工良 阅读全文

小肥橘 [......] 继续阅读

2022年5月28日 2条评论 3573点热度 0人点赞 痴者工良 阅读全文
 />            </a>
        </div>
        <div class=

[TOC] A while ago, I came across the concept of LSM Tree while studying data structures, which prompted me to attempt building a simple KV database based on the design principles of LSM Tree. The code has been open-sourced, and the repository can be found at: …

2022年5月22日 1条评论 794点热度 1人点赞 痴者工良 阅读全文

[TOC] 笔者前段时间在学习数据结构时,恰好听说了 LSM Tree,于是试着通过 LSM Tree 的设计思想,自己实现一个简单的 KV 数据库。 代码已开源,代码仓库地址:https://github.com/whuanle/lsm 笔者使用 Go 语言来实现 LSM Tree 数据库,因为 LSM Tree 的实现要求对文件进行读写、锁的处理、数据查找、文件压缩等,所以编码过程中也提高了对 Go 的使用经验,项目中也使用到了一些栈、二叉排序树等简单的算法,也可以巩固了基础算法能力。适当给自己设定挑战目标,可…

2022年5月22日 1条评论 3687点热度 1人点赞 痴者工良 阅读全文

Pursuit is not about getting what you wish for, but rather about the twists and turns of fate. [......] 继续阅读

2022年5月11日 0条评论 632点热度 0人点赞 痴者工良 阅读全文

追求,不是如愿以偿,而是阴差阳错 [......] 继续阅读

2022年5月11日 0条评论 2948点热度 0人点赞 痴者工良 阅读全文

Face yourself and maintain a calm mindset. Everyone goes through periods of underestimation and discomfort, and there are many things that cause us pain. It's natural to hope for someone to accompany you. In fact, instead of focusing on finding someone to shar…

2022年5月10日 0条评论 3212点热度 0人点赞 痴者工良 阅读全文

要正视自己,放平心态,每个人处于低估和难受的时期,很多事让自己痛苦,希望可以找一个人一起陪伴。 其实,不用管想着有人陪伴你受苦,经历磨难。而是你应该经历苦难后,走出低谷,摆脱困境,这才是当前最应该做的事情。 即使是找到另一半,别人也没有义务承担你的痛苦,何必在痛苦的时候,让另一个也痛苦呢。 悲喜自渡。 [......] 继续阅读

2022年5月10日 0条评论 3076点热度 0人点赞 痴者工良 阅读全文

Title: Given an integer array nums. Return true if any value appears at least twice in the array, and return false if every element is distinct. Example 1: Input: nums = [1,2,3,1] Output: true Example 2: Input: nums = [1,2,3,4] Output: false Example 3: Input: …

2022年4月17日 0条评论 2564点热度 0人点赞 痴者工良 阅读全文

题目: 给你一个整数数组 nums 。如果任一值在数组中出现 至少两次 ,返回 true ;如果数组中每个元素互不相同,返回 false 。 示例 1: 输入:nums = [1,2,3,1] 输出:true 示例 2: 输入:nums = [1,2,3,4] 输出:false 示例 3: 输入:nums = [1,1,1,3,3,4,3,2,4,2] 输出:true 提示: 1 <= nums.length <= 105 -109 <= nums[i] <= 109 来源:力扣(LeetC…

2022年4月17日 0条评论 2428点热度 0人点赞 痴者工良 阅读全文

第一种: private bool IsDefaultValue(T value) { Span<byte> valueBytes = MemoryMarshal.AsBytes<T>(new T []{ value }.AsSpan()); var defaultBytes = new byte[valueBytes.Length]; return valueBytes.SequenceEqual(defaultBytes); } 第二种: public class Test<T&g…

2022年4月3日 0条评论 3794点热度 2人点赞 痴者工良 阅读全文

第一种: private bool IsDefaultValue(T value) { Span<byte> valueBytes = MemoryMarshal.AsBytes<T>(new T []{ value }.AsSpan()); var defaultBytes = new byte[valueBytes.Length]; return valueBytes.SequenceEqual(defaultBytes); } 第二种: public class Test<T&g…

2022年4月3日 0条评论 3696点热度 2人点赞 痴者工良 阅读全文

<ItemGroup> <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0-preview.2.22152.2" /> <PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0-preview.2.22152.2&qu…

2022年3月31日 1条评论 4323点热度 1人点赞 痴者工良 阅读全文

<ItemGroup> <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0-preview.2.22152.2" /> <PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0-preview.2.22152.2" /> <PackageReference Include="…

2022年3月31日 1条评论 4674点热度 1人点赞 痴者工良 阅读全文

Using interfaces has another benefit: it facilitates mocking. To evaluate whether your code is good, properly separated, or over-designed, write comprehensive unit tests for yourself. If it's difficult or impossible to write unit tests for your own code, then …

2022年3月30日 0条评论 604点热度 0人点赞 痴者工良 阅读全文

使用接口的另一个好处是,方便 mock。 要检验自己代码是否好,足够分离,是否过度设计等,给自己写完整的单元测试。 如果自己写的代码,单元测试很难写或者无从下手,那么就要考虑改进代码了。 首先在单元测试类中,mock 注入服务: public class BasketWebApiTest { private readonly Mock<IBasketRepository> _basketRepositoryMock; private readonly Mock<IBasketIdentitySer…

2022年3月30日 0条评论 2816点热度 0人点赞 痴者工良 阅读全文
1171819202154