Radar · Go · Archive · Week 16 · Apr 14 – 20, 2025
Pluggable history API for `golang.org/x/term`
Worth knowingecosystem
- What changed
- The proposal adds a
Historyinterface and aTerminalfield that records input lines read byReadLine. - Production impact
- The source does not say.
- Try it
- Create a
Terminal, callReadLine, and useHistory.AddandHistory.Atto inspect the history. - Source
- github.com/golang/go/issues/68780
Understand it, then run it
The golang.org/x/term package now lets you plug in your own history mechanism. When you type a line in a terminal, the library keeps a record of that line so you can press the up arrow to see previous commands. The new History interface lets you decide how many lines to keep, whether to drop empty lines, or to store them in a file. Terminal now has a History field that holds whatever implementation you choose.
Written by gpt-oss-20b from the linked source · claims checked against the sources · archive, not individually reviewed