Human-friendly Go module that builds and prints directory trees using ASCII art

Overview

Go Reference Codacy Quality Codacy Coverage

asciitree

Human-friendly Go module that builds and prints directory trees using ASCII art.

Installation

go get github.com/borodean/asciitree

Usage

// Build a directory tree representation:
tree := asciitree.NewDir("albums").Add(
  asciitree.NewFile("ONUKA.jpg"),
  asciitree.NewDir("VIDLIK").AddFiles(
    "Svitanok.mp3",
    "Vidlik.mp3",
  ),
  asciitree.NewDir("KOLIR").AddFiles(
    "CEAHC.mp3",
    "ZENIT.mp3",
    "UYAVY (feat. DakhaBrakha).mp3",
    "XASHI.mp3",
  ),
)

// Sort the tree's descendants alphanumerically while placing directories
// before files:
tree.Sort(asciitree.WithDirsFirst(true))

// Print an ASCII art representation of the directory tree:
fmt.Println(tree)

License

MIT.

Issues
  • Add benchmarks

    Add benchmarks

    This PR benchmarks some of the heavier functions and optimizes them.

    Before:

    cpu: Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz
    BenchmarkNodeAdd-8           3905551           300.2 ns/op
    BenchmarkAddDirs-8           1657606           719.6 ns/op
    BenchmarkAddFiles-8          1607150           742.3 ns/op
    BenchmarkNodeSort-8           586012          2095 ns/op
    BenchmarkNodeString-8         511766          2334 ns/op
    

    After:

    cpu: Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz
    BenchmarkNodeAdd-8          14195162            86.82 ns/op
    BenchmarkAddDirs-8           2131742           565.4 ns/op
    BenchmarkAddFiles-8          2171773           556.3 ns/op
    BenchmarkNodeSort-8           766713          1552 ns/op
    BenchmarkNodeString-8         906979          1336 ns/op
    

    Improvement:

    cpu: Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz
    BenchmarkNodeAdd-8               -71 %
    BenchmarkAddDirs-8               -21 %
    BenchmarkAddFiles-8              -25 %
    BenchmarkNodeSort-8              -26 %
    BenchmarkNodeString-8            -43 %
    
    opened by borodean 0
  • Simplify API, second attempt

    Simplify API, second attempt

    This PR:

    • Uses "Files/Directories" terminology instead of "Leaves/Branches".
    • Renames NewChild<noun> to Add<noun>.
    • Exports the methods of the Node struct.
    opened by borodean 0
  • Add documentation

    Add documentation

    This PR:

    • Sets up a workflow to generate README.md based on go doc using goreadme.
    • Adds essential documentation to all exported entities.

    Apart from that:

    • Merges the Tree interface and the tree struct into a single entity.
    • Renames WithDirsFirst to WithBranchesFirst.
    • Fine-tunes the visibility of entities.
    • Renames the testing workflow to test.
    opened by borodean 0
  • Set up a continuous integration

    Set up a continuous integration

    This PR:

    • Sets up a workflow to run go test on Go v1.16 and v1.17 (the versions currently supported by Go).
    • Automates coverage reports submission to Codacy.
    opened by borodean 0
Owner
Vadym Borodin
Señor Software Engeeneer
Vadym Borodin
asciigrid is a Go package that implements decoder and encoder for the Esri ASCII grid format, also known as ARC/INFO ASCII GRID.

asciigrid asciigrid is a Go package that implements decoder and encoder for the Esri ASCII grid format, also known as ARC/INFO ASCII GRID. Install go

Ahmet Artu Yildirim 0 Oct 16, 2021
A cross-platform tool to convert images into ascii art and print them on the console

A cross-platform tool to convert images into ascii art and print them on the console

Zoraiz Hassan 828 May 20, 2022
A simple javascript website that takes user input, queries a Go based backend which then creates ascii art and sends it back to the frontend

A simple javascript website that takes user input, queries a Go based backend which then creates ascii art and sends it back to the frontend. Finally the site displays the ascii art and offers the option to download as multiple file types.

null 0 Jan 7, 2022
Ascii-art-web

ASCII-ART-WEB Author: Alika96 How to run Run the following commands: For building an image: docker image build -t ascii-art-web-docker . For showing i

null 0 Dec 13, 2021
API for generate image to ASCII Art

ASCII API Generate ASCII art from image. You can try this API here: ascii.projec

Sh4yn 3 Mar 10, 2022
A command to output longified ascii art.

longify A command to output longified ascii art. Inspired by Tweet from @sheepla: https://twitter.com/Sheeeeepla/status/1522199846870196225 Installati

syumai 7 May 6, 2022
📸 Clean your image folder using perceptual hashing and BK-trees using Go!

Image Cleaner ?? ?? ➡ ?? This tool can take your image gallery and create a new folder with image-alike-cluster folders. It uses a perceptual image ha

lord_santanna 6 Sep 1, 2021
Convert images to computer generated art using delaunay triangulation.

▲ Triangle is a tool for generating triangulated image using delaunay triangulation. It takes a source image and converts it to an abstract image comp

Endre Simo 1.9k May 18, 2022
:foggy: Convert image to ASCII

?? Image2ascii Image2ASCII is a library that converts images into ASCII images and provides command-line tools for easy use. Installation go get githu

秦世成 661 May 16, 2022
3D line art engine.

ln The 3D Line Art Engine ln is a vector-based 3D renderer written in Go. It is used to produce 2D vector graphics (think SVGs) depicting 3D scenes. T

Michael Fogleman 3.1k May 18, 2022
generativeart is a Go package to generate many kinds of generative art.

generativeart is a Go package to generate many kinds of generative art. The goal is to collect some excellent generative art (implemented in R or Processing), and rewrite them in Go again

null 733 May 11, 2022
Generate high-quality triangulated art from images.

An iterative algorithm to generate high quality triangulated images.

null 53 May 26, 2021
The imghdr module determines the type of image contained in a file for go

goimghdr Inspired by Python's imghdr Installation go get github.com/corona10/goimghdr List of return value Value Image format "rgb" SGI ImgLib Files

Dong-hee Na 38 Jan 23, 2022
A golang wrapper module to interact with `fit-statUSB` device over serial.

go-fitstatusb A golang wrapper module to interact with fit-statUSB device over serial. This is experimental at best, not ready for production. Backgro

Nicholas Granado 0 Feb 4, 2022
Go package for computer vision using OpenCV 4 and beyond.

GoCV The GoCV package provides Go language bindings for the OpenCV 4 computer vision library. The GoCV package supports the latest releases of Go and

The Hybrid Group 4.8k May 15, 2022
go-pix is a Go library for generating Pix transactions using Copy and Paste or QR codes. 💳 💰

go-pix go-pix is a Go library for generating Pix transactions using Copy and Paste or QR codes.

Jonnas Fonini 59 Mar 14, 2022
A Pong clone made from scratch with Go and C using OpenGL 3.3

Go-Pong A Pong video game clone made with Go lang and OpenGL 3.3 using C. Gameplay Offline Key bindings are 'w' and 's' for the left player and 'up ar

Mohammad Issawi 33 Feb 10, 2022
User programmable screen overlay using web technologies

Topframe User programmable screen overlay using web technologies Display information and always-on-top widgets Use HTML/JS/CSS to draw on your screen

Jeff Lindsay 311 May 6, 2022
Canvas is a Go drawing library based on OpenGL or using software rendering that is very similar to the HTML5 canvas API

Go canvas Canvas is a pure Go library that provides drawing functionality as similar as possible to the HTML5 canvas API. It has nothing to do with HT

Thomas Friedel 423 May 5, 2022