goclean

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 16, 2026 License: MIT Imports: 3 Imported by: 0

README

goclean

Cross-platform terminal screen clearing and cursor control for Go.

Installation

go get github.com/sonnt85/goclean

Features

  • Clear the terminal screen on Linux, macOS, and Windows
  • Move the cursor to the top-left position
  • Query terminal width and height
  • Native Windows implementation via kernel32.dll (no ANSI codes)
  • ANSI escape code implementation for Unix-like systems

Usage

package main

import (
    "fmt"
    "time"

    "github.com/sonnt85/goclean"
)

func main() {
    goclean.Clear()

    for {
        goclean.MoveTopLeft()

        w, h := goclean.Size()
        fmt.Printf("Width: %d Height: %d\n", w, h)
        fmt.Println(time.Now())

        time.Sleep(time.Second)
    }
}

API

  • Clear() — clears the terminal screen
  • MoveTopLeft() — moves the cursor to position (0, 0)
  • Size() (int, int) — returns terminal width and height in columns/rows

Author

sonnt85thanhson.rf@gmail.com

License

MIT License - see LICENSE for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clear

func Clear()

Clear clears the screen

func MoveTopLeft

func MoveTopLeft()

MoveTopLeft moves the cursor to the top left position of the screen

func Size

func Size() (int, int)

Size returns the width and height of the terminal screen

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL