magic8ball

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2023 License: MIT Imports: 4 Imported by: 0

README

Magic 8 Ball

Build Status Go Report Card Docs License

Simple Magic 8 Ball package.

CLI

% go install github.com/grokify/go-magic8ball/cmd/magic8ball
% magic8ball

Library

See the docs: at pkg.go.dev/github.com/grokify/go-magic8ball

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrResponseNotFound = errors.New("response not found")

ErrResponseNotFound is the error when a supplied 8 ball response isn't found.

Functions

func Intn added in v0.1.1

func Intn(n uint) int

Intn returns a random number backed by `crypto/rand`.

func ResponseType

func ResponseType(r string) (int, error)

ResponseType returns whether a response is positive, neutral, or negative. Values returned are `1` for positive, `0` for neutral, and `-1` for negative.

func Shake

func Shake() string

Shake returns a Magic 8 Ball response. It returns an error if `crypto/rand` fails.

Types

type CryptoRandSource added in v0.1.1

type CryptoRandSource struct{}

CryptoRandSource is a `crypto/rand` backed source that satisfies the `math/rand.Source` interface definition. It can be used as `r := rand.New(NewCryptoRandSource())` See: https://stackoverflow.com/a/35208651/1908967

func NewCryptoRandSource added in v0.1.1

func NewCryptoRandSource() CryptoRandSource

func (CryptoRandSource) Int63 added in v0.1.1

func (CryptoRandSource) Int63() int64

func (CryptoRandSource) Seed added in v0.1.1

func (CryptoRandSource) Seed(int64)

Directories

Path Synopsis
cmd
magic8ball command

Jump to

Keyboard shortcuts

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