How to Create Console Screen Buffer in go?

This page summarizes the projects mentioned and recommended in the original post on /r/golang

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • tcell

    Tcell is an alternate terminal package, similar in some ways to termbox, but better in others.

  • Hi guys, I have fixed the problem. The problem was as stated: remove terminal behavior like when a key is pressed and held it does not work as needed. For example if I want to move character when user press key the player (character) will move one step then stops then move fast like text curser. The solution is not by using [Console Screen Buffer] the Tcell is enough, But the problem is caused by the way the input is read from the user as u/pekim says in comments it is a "Typical behaviour in most environments (not just Windows)". So to fix this you need to use windows API (w32) and read key using GetAsyncKeyState() that will fix the problem.

  • go-ansi

    Windows-portable ANSI escape sequence utility for Go language

  • There is an older, not-so-well documented package out there called https://github.com/k0kubun/go-ansi which I use when I want to "write stuff in place" on a single line in the Windows console. I know the package says that it uses Ansi keystrokes, but if you look at the actual source in the package, for Windows anyway it seems to directly make Windows Console buffer commands. If the other suggestions work for you, then great, if not, this could work, with a little work.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • w32

    A wrapper of Windows APIs for the Go Programming Language.

  • Hi guys, I have fixed the problem. The problem was as stated: remove terminal behavior like when a key is pressed and held it does not work as needed. For example if I want to move character when user press key the player (character) will move one step then stops then move fast like text curser. The solution is not by using [Console Screen Buffer] the Tcell is enough, But the problem is caused by the way the input is read from the user as u/pekim says in comments it is a "Typical behaviour in most environments (not just Windows)". So to fix this you need to use windows API (w32) and read key using GetAsyncKeyState() that will fix the problem.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts