Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Go 1.24 のイテレータ from byte to bite

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
Avatar for Nozomu Ikuta Nozomu Ikuta
February 25, 2025

Go 1.24 のイテレータ from byte to bite

CA.go ~ Deep dive into Go1.24 ~ の登壇資料です

Avatar for Nozomu Ikuta

Nozomu Ikuta

February 25, 2025
Tweet

More Decks by Nozomu Ikuta

Other Decks in Technology

Transcript

  1. ΠςϨʔλ͓͞Β͍ • ͻͱͭͷ஋ΛΘͨ͢: Seq[V any] func(yield func(V) bool) • slices.All()

    • slices.Values() • slices.Backward() • slices.Sorted() • etc.
  2. func Lines(s []byte) iter.Seq[[]byte] • newlineʢվߦʣͷ௚ޙͰ byte Λ۠ ੾ͬͯฦͯ͘͠ΕΔ •

    ֤஋͸຤ඌʹվߦ͕͍ͭͯ͘Δ • byte ຤ඌͷվߦͷ༗ແ͸ଚॏ͞Ε Δ bytes ύοέʔδͷΠςϨʔλ
  3. func SplitSeq(s, sep []byte) iter.Seq[[]byte] • ೚ҙͷ byte slice Ͱ۠੾ͬͯฦͯ͠

    ͘ΕΔ • ֤஋຤ඌʹ۠੾Γ෦෼Λ;͘·ͳ͍ bytes ύοέʔδͷΠςϨʔλ
  4. func SplitAfterSeq(s, sep []byte) iter.Seq[[]byte] • ೚ҙͷ byte slice Ͱ۠੾ͬͯฦͯ͠

    ͘ΕΔ • ֤஋຤ඌʹ۠੾Γ෦෼Λ;͘Ή bytes ύοέʔδͷΠςϨʔλ
  5. • ೚ҙͷؔ਺Ͱ byte Λ۠੾ͬͯฦ͠ ͯ͘ΕΔ • unicode.IsX() ϝιουͳͲͱ૊Έ߹ Θͤͯ࢖͏ •

    ֤஋͸લޙʹ۠੾Γ෦෼Λ;͘·ͳ ͍ bytes ύοέʔδͷΠςϨʔλ func FieldsFuncSeq(s []byte, f func(rune) bool) iter.Seq[[]byte]