技術的自由への長い道

日々学んでいきます。

2022-09-01から1ヶ月間の記事一覧

react-testing-libraryのtoBeとtoEqualの違い

toBeがcheckByReferenceでtoEqualがcheckByValueOnRecursive いくつか例を挙げておく expect(1).toBe("1") -> false expect(1).toEqual("1") -> false let a = { foo:"bar" } let b = { foo:"bar" } expect(a).toBe(b) -> false expect(a).toEqual(b) -> tru…

golang io.Copyとio.ReadFullの違いについて

io.Copyとio.ReadFullどっちを使えばいいかよくわかってなかったので調べた。 結論 io.ReadFullはbufSizeを指定しなきゃいけないっぽくて、io.CopyはbufSize指定しなくてよし func ReadFull(r Reader, buf []byte) (n int, err error) { return ReadAtLeast(…

Go言語による分散サービス 第三章修正点

第三章 index.goのClose() 下記のようにi.mmap.Syncではなく、i.mmap.UnsafeUnmapをしないとi.file.Truncateでエラーが出てしまう func (i *index) Close() error { // //mmap上のファイルデータをメモリ上のファイルデータに同期 // if err := i.mmap.Sync(…

#ゆめみからの挑戦状 ★第5弾での学び

問題 'two', 'four' => '4th'], 'three' => '3rd', ['one' => '1st'], '10th' => 'ten', ['6th' => 'six'], '5th' => 'five', 'seven' => '7th', ['fourteen' => '14th', '11th' => 'eleven'], ['8th' => 'eight'], 'thirteen' => '13th', '12th' => 'twelv…