Git Product home page Git Product logo

fortune-go's Introduction

Fortune program in Go

Intro

fortune is a stripped-down implementation of the classic BSD Unix fortune command: It selects a random fortune cookie saying from a file and displays it on standard output.

Unlike the BSD fortune command (or my own Python version, at https://github.com/bmc/fortune), this version does not use an index file. We have loads of memory these days, and fortunes files aren't that big, so it's feasible to load the whole text file in memory, parse it on the fly, and randomly choose a resulting fortune.

This version is written in Go, mostly because, why not?

Installation

The easiest way to install this program is via the go command. Make sure your GOPATH is set to something, and ensure that $GOPATH/bin is in your PATH. Then:

go get github.com/bmc/fortune-go

A program called fortune-go will end up in your $GOPATH/bin directory.

Usage

fortune [/path/to/fortune/cookie/file]
fortune -h|--help

If you don't specify a fortune cookie file path (see below), fortune defaults to the contents of the FORTUNE_FILE environment variable. If neither the argument nor the FORTUNE_FILE variable is present, fortune aborts.

Fortune Cookie File Format

A fortune cookie file is a text file full of quotes. The format is simple: The file consists of paragraphs separated by lines containing a single '%' character. For example::

A little caution outflanks a large cavalry.
    -- Bismarck
%
A little retrospection shows that although many fine, useful software
systems have been designed by committees and built as part of multipart
projects, those software systems that have excited passionate fans are
those that are the products of one or a few designing minds, great
designers. Consider Unix, APL, Pascal, Modula, the Smalltalk interface,
even Fortran; and contrast them with Cobol, PL/I, Algol, MVS/370, and
MS-DOS.
    -- Fred Brooks, Jr.
%
A man is not old until regrets take the place of dreams.
    -- John Barrymore

You're more than welcome to my fortune cookie file. It's over here: https://github.com/bmc/fortunes.

License and Copyright

See the accompanying License file.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.