package module
Version: v0.0.0-...-9b04b4a Latest Latest

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

Go to latest
Published: Sep 18, 2016 License: MIT Imports: 5 Imported by: 0



Generate random adjective-noun combinations, madlibs-style, in Golang. Inspired by kylestetz's Sentencer (node.js module).

"Oh look, {{ an adjective }} {{ noun }}!"

becomes something like (it's random!):

"Oh look, a tameless recorder!"

sententia uses Go's text/template to identify the places where a new noun or adjective should be generated.

Use cases

  • Creating random IDs a la Heroku
  • Generating lorem ipsums
  • Fun
  • ??
  • Profit


Download the lib.

go get
package main

import (


func main() {
	sentence, err := sententia.Make("Aw yis, {{ adjective }} {{ nouns }}.")
	if err != nil {


Built in actions are:


Picks a random noun and replaces it in the input.

sententia.Make("{{ noun }}")
// => "avenue", "knot", "show", "narcissus"


Picks a random noun and pluralizes it.

sententia.Make("{{ noun }}")
// => "harbors", "pumps", "overcoats", "gongs"


Is replaced in the template by a random adjective.

sententia.Make("{{ adjective }}")
// => "sprightful", "naif", "glowing", "surfy"

a and an

Can be used with adjective and noun to prefix them with an article (either "a" or "an")

sententia.Make("{{ a noun }}")
// => "a romanian", "an archer", "a tyvek"
sententia.Make("{{ an adjective }}")
// => "a sphygmic", "a clubby", "an uncocked", "a bumbling"

These all can be mixed to provide beautiful nonsensic sentences:

  "Once I had {{ an adjective }} {{ noun }} full of {{ nouns }} but they flew into {{ a noun }}.",
// => "Once I had a spleeny wallet full of toilets but they flew into an orchestra."

Extending sententia

Adjectives and nouns

sententia can be extended by adding custom nouns or adjectives, or overwriting the built-in ones.

customNouns := []string{"potato", "carrot", "letuce"}
sententia.AddNouns(nouns) // Apepnds the new nouns to the existent ones.
sententia.SetNouns(nouns) // Overwrites the existent nouns.

customAdjectives := []string{"delicious", "earthy", "healthy"}
sententia.AddAdjectives(customAdjectives) // Apepnds the new adjectives to the existent ones.
sententia.SetAdjectives(customAdjectives) // Overwrites existent adjectives.


Because sententia is based on Go's text/template package, we can also compose actions by feeding their output into other ones. For example, we could write an action to turn a noun into title case, where the first letter is upper case:

package main

import (


func main() {
	customActions := map[string]interface{}{
		"capitalize": strings.Title,
	sentence, err := sententia.Make(
		"She wrote a book called '{{ capitalize (an adjective) }} {{ capitalize noun }}'",
	if err != nil {

Then, we could get something like "She wrote a book called 'A Subdued Duckling'". Notice we have to group the actions with () for Go to interpret their output as input to capitalize. If you want a refresher on how Go templates handle arguments, check this out!




This section is empty.


This section is empty.


func AddActions

func AddActions(customActions map[string]interface{})

AddActions merges new actions to the default ones.

func AddAdjectives

func AddAdjectives(customAdjectives []string)

AddAdjectives appends a custom adjective list to the built-in one.

func AddNouns

func AddNouns(customNouns []string)

AddNouns appends a custom noun list to the built-in one.

func Make

func Make(sentence string) (string, error)

Make generates a sentence replacing the noun and adjective templates.

func SetAdjectives

func SetAdjectives(customAdjectives []string)

SetAdjectives replaces the built-in adjective list with a custom one.

func SetNouns

func SetNouns(customNouns []string)

SetNouns replaces the built-in noun list with a custom one.


This section is empty.

Jump to

Keyboard shortcuts

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