mbar

package module
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2026 License: GPL-3.0 Imports: 7 Imported by: 0

README

         ____     ______  ____       
 /'\_/`\/\  _`\  /\  _  \/\  _`\     
/\      \ \ \L\ \\ \ \L\ \ \ \L\ \   
\ \ \__\ \ \  _ <'\ \  __ \ \ ,  /   
 \ \ \_/\ \ \ \L\ \\ \ \/\ \ \ \\ \  
  \ \_\\ \_\ \____/ \ \_\ \_\ \_\ \_\
   \/_/ \/_/\/___/   \/_/\/_/\/_/\/ /

A shitty multi-line bar for Go
GitHub License GitHub tag (with filter) CodeFactor GitHub code size in bytes

Installation

go get github.com/ItzAfroBoy/mbar@latest

Example

package main

import (
 "io"
 "net/http"
 "os"

 "github.com/ItzAfroBoy/mbar"
)

func main() {
    mb := mbar.NewMBar(mbar.Config{ShowTime: true, ShowSpeed: true, ShowSize: true})
    res, err := http.Get("https://ash-speed.hetzner.com/100MB.bin")
    if err != nil {
        panic(err)
    }
    defer res.Body.Close()
    bar := mb.Add("100MB.bin", int(res.ContentLength))
    file, err := os.Create("100MB.bin")
    if err != nil {
        panic(err)
    }
    io.Copy(io.MultiWriter(file, bar), res.Body)
    mb.Finish("Done")
}

Documentation

Overview

A multi-progressbar solution. Supports I/O operations only at this point in development

Example
package main

import (
	"io"
	"net/http"
	"os"

	"github.com/ItzAfroBoy/mbar"
)

func main() {
	mb := mbar.NewMBar(mbar.Config{ShowTime: true, ShowSpeed: true, ShowSize: true})
	res, err := http.Get("https://ash-speed.hetzner.com/100MB.bin")
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()
	bar := mb.Add("100MB.bin", int(res.ContentLength))
	file, err := os.Create("100MB.bin")
	if err != nil {
		panic(err)
	}
	io.Copy(io.MultiWriter(file, bar), res.Body)
	mb.Finish("Done")
}

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bar

type Bar struct {
	// Title of the bar
	Title string
	// The full size of the object being operated on
	Size int
	// Config for the displaying of info to the bar
	Config Config
	// contains filtered or unexported fields
}

func (*Bar) Write

func (b *Bar) Write(p []byte) (n int, err error)

io.writer implementation

type Config

type Config struct {
	ShowTime  bool
	ShowSpeed bool
	ShowSize  bool
}

type MBar

type MBar struct {
	// Number of bars
	NumBars int
	// Config for the displaying of info to the bar
	Config Config
	// contains filtered or unexported fields
}

func NewMBar

func NewMBar(config Config) *MBar

Returns a new nulti-bar instance

func (*MBar) Add

func (m *MBar) Add(title string, size int) *Bar

Add will add a new bar to the multi-bar instance.

func (*MBar) Finish

func (m *MBar) Finish(msg string)

Finish is the final function when all bars are done. It must be called to reset the cursor's position for output purposes.

func (*MBar) Start

func (m *MBar) Start()

Start will update the bar whenever the Write function is called. This must be called before any I/O operations have begun

BUG(Brett): Fonts with ligitures enabled may have unexpected behaviour

Notes

Bugs

  • Fonts with ligitures enabled may have unexpected behaviour

Jump to

Keyboard shortcuts

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