[go-fan] Go Module Review: rivo/uniseg

Geschlossen Anfängerfreundlich
#75,360 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
72/100
Issue-Typ
Feature
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
go
Bereich
testing

Rechercherichtung

Beginne in pkg/cli/add_package_manifest_parse.go und lies isEmojiString und isEmojiGrapheme, um zu sehen, wie Icon-Zeichenfolgen validiert werden. Füge Tabellen-Tests hinzu, die die aufgeführten Graphem- und Zeichenfolgenfälle abdecken, und führe anschließend die relevanten Go-Tests aus. Als abgeschlossen gilt die Aufgabe, wenn die Tests beide Funktionen ausführen und das beabsichtigte großzügige Validierungsverhalten bestätigen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

automation cookie

🐹 Go Fan Report: rivo/uniseg

Module Overview

github.com/rivo/uniseg implements Unicode text segmentation (grapheme clusters, words, sentences, line breaks) and monospace string width.

Current Usage in gh-aw

  • Files: 1 file (pkg/cli/add_package_manifest_parse.go)
  • Import Count: 1
  • Version: v0.4.7 (latest tag)
  • Key APIs Used: uniseg.NewGraphemes, Graphemes.Next, Graphemes.Runes, all in isEmojiString, which validates the manifest icon field. Each grapheme cluster is checked by isEmojiGrapheme, which uses hand-written code-point ranges.
  • Terminal width is not measured with uniseg. lipgloss.Width and ansi.StringWidth are used instead.

Research Findings

Recent Updates
  • The last substantive default-branch commit is from 2024-04-13. v0.4.7 fixed variation-selector width. v0.4.5 added EastAsianAmbiguousWidth, and v0.4.6 included performance work. The repo pushed_at of 2026-11-05 shows no new release or default-branch commit in the tools used.
Best Practices
  • Use FirstGraphemeClusterInString or GraphemeClusterCount when the iterator state is not needed. They avoid allocation.

Improvement Opportunities

🏃 Quick Wins
  • Add a table test for isEmojiString and isEmojiGrapheme. No test calls them directly. Cover ZWJ families, skin-tone modifiers, flags, keycaps, ©, plain ASCII, mixed strings and :octicon-name:.
✨ Feature Opportunities
  • None needed today. StringWidth with EastAsianAmbiguousWidth is available but width is handled by the Charm stack.
📐 Best Practice Alignment
  • The base ranges 0x2300–0x23ff and 0x2600–0x27bf accept some non-emoji symbols. That is fine for a lenient icon check, but a comment would document the intent.
🔧 General Improvements
  • Replacing Graphemes.Runes() with FirstGraphemeClusterInString would reduce allocations. This is a micro-optimisation since the check runs once per manifest.
  • uniseg is a direct dependency used in a single function. github.com/clipperhouse/uax29/v2 is already an indirect dependency and could provide grapheme segmentation, which would let uniseg be dropped. This was not verified: shell access was denied mid-run, so go mod why -m github.com/rivo/uniseg and test-coverage checks were not run.

Recommendations

  1. Add unit tests for isEmojiString (high value, low effort).
  2. Run go mod why -m github.com/rivo/uniseg and decide whether to consolidate on uax29.
  3. Optionally switch to FirstGraphemeClusterInString.

Next Steps

  • Open a small PR for the tests. Evaluate the dependency consolidation separately.

Generated by Go Fan
Module summary saved to: scratchpad/mods/rivo-uniseg.md

Generated by 🐹 Go Fan · claude · routed: sonnet55 high · ~25 AIC · ⌖ ~1 AIC · ⊞ 5.7K · ◷

  • expires on Nov 7, 2026, 12:05 AM UTC-08:00
Vorherrschende Sprache
Go
Sterne
5.6k
Forks
615
Ø Merge
5 Std. 29 Min.
Gemergte PRs (30 T.)
806

Entwicklungsumgebung

In Codespaces öffnen

Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus github/gh-aw

Alle Issues in github/gh-aw

Ähnliche Issues

Weitere Issues zu Go

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.