Skip to content

Latest commit

 

History

History
62 lines (42 loc) · 1.46 KB

README.md

File metadata and controls

62 lines (42 loc) · 1.46 KB

randhex

Build Status Coverage Status Go Report Card GoDoc

A library for generating random hexadecimal color codes

License

MIT

Installation

$ go get github.com/frankenbeanies/randhex

Usage

import "github.com/frankenbeanies/randhex

Methods

New()

Generates a new random hexadecimal color code (RandHex)

hex := randhex.New()

String()

Provides a string representation of the RandHex prepended with '#'

hexStr := randhex.New().String()

Bytes()

Provides the byte representation of the RandHex

hexBytes := randHex.New().Bytes()

ParseString()

Parses string into a RandHex

hex, _ := randhex.ParseString("#aaa")
hex, _ := randhex.ParseString("#AAAAAA")
hex, _ := randhex.ParseString("aaa")
_, err := randhex.ParseString("a") //error, bad length
_, err := randhex.ParseString("%aaa") //error, bad symbol
_, err := randhex.ParseString("#gaa") //error, not hex