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

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.

Similar Resources

generativeart is a Go package to generate many kinds of generative art.

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

Dec 29, 2022

Generate high-quality triangulated art from images.

Generate high-quality triangulated art from images.

An iterative algorithm to generate high quality triangulated images.

May 26, 2021

The imghdr module determines the type of image contained in a file for go

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

Oct 10, 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

Feb 4, 2022

Go package for computer vision using OpenCV 4 and beyond.

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

Jan 1, 2023

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

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.

Sep 12, 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

Feb 10, 2022

User programmable screen overlay using web technologies

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

Dec 29, 2022

Canvas is a Go drawing library based on OpenGL or using software rendering that is very similar to the HTML5 canvas API

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

Jan 3, 2023
Comments
  • 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 %
    
  • 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.
  • 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.
  • 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.
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

Jul 3, 2022
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

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

Dec 30, 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.

Jan 7, 2022
Ascii-art-web
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

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

Jul 1, 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

Sep 12, 2022
📸 Clean your image folder using perceptual hashing and BK-trees using Go!
📸 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

Oct 8, 2022
Convert images to computer generated art using delaunay triangulation.
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

Dec 29, 2022
:foggy: Convert image to ASCII
: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

Jan 8, 2023
3D line art engine.
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

Dec 28, 2022