haikunator

package module
Version: v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2016 License: BSD-3-Clause Imports: 4 Imported by: 1

README

HaikunatorGO

Build Status Coverage Status Go Report Card GoDoc

Generate Heroku-like random names to use in your go applications.

Installation

go get github.com/atrox/haikunatorgo

Usage

Haikunator is pretty simple.

package main

import (
  haikunator "github.com/atrox/haikunatorgo"
)

func main() {
  haikunator := haikunator.New()

  // default usage
  haikunator.Haikunate() // => "wispy-dust-1337"

  // custom length (default=4)
  haikunator.TokenLength = 9
  haikunator.Haikunate() // => "patient-king-887265"

  // use hex instead of numbers
  haikunator.TokenHex = true
  haikunator.Haikunate() // => "purple-breeze-98e1"

  // use custom chars instead of numbers/hex
  haikunator.TokenChars = "HAIKUNATE"
  haikunator.Haikunate() // => "summer-atom-IHEA"

  // don't include a token
  haikunator.TokenLength = 0
  haikunator.Haikunate() // => "cold-wildflower"

  // use a different delimiter
  haikunator.Delimiter = "."
  haikunator.Haikunate() // => "restless.sea.7976"

  // no token, space delimiter
  haikunator.TokenLength = 0
  haikunator.Delimiter = " "
  haikunator.Haikunate() // => "delicate haze"

  // no token, empty delimiter
  haikunator.TokenLength = 0
  haikunator.Delimiter = ""
  haikunator.Haikunate() // => "billowingleaf"

  // custom nouns and/or adjectives
  haikunator.Adjectives = []string{"red", "green", "blue"}
  haikunator.Nouns = []string{"reindeer"}
  haikunator.Haikunate() // => "blue-reindeer-4252"
}

Options

The following options are available:

Haikunator{
  Adjectives:  []string{"custom", "adjectives"},
  Nouns:       []string{"custom", "nouns"},
  Delimiter:   "-",
  TokenLength: 4,
  TokenHex:    false,
  TokenChars:  "0123456789",
  Random:      rand.New(rand.NewSource(time.Now().UnixNano())),
}

If TokenHex is true, it overrides any tokens specified in TokenChars

Contributing

Everyone is encouraged to help improve this project. Here are a few ways you can help:

Other Languages

Haikunator is also available in other languages. Check them out:

Documentation

Overview

Package haikunator generates Heroku-like random names to use in your go applications

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Haikunator

type Haikunator struct {
	Adjectives  []string
	Nouns       []string
	Delimiter   string
	TokenLength int
	TokenHex    bool
	TokenChars  string
	Random      *rand.Rand
}

A Haikunator represents all options needed to use haikunate()

func New

func New() *Haikunator

New creates a new Haikunator with all default options

func (*Haikunator) Haikunate

func (h *Haikunator) Haikunate() string

Haikunate generates a random Heroku-like string

Source Files

Jump to

Keyboard shortcuts

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