common

package
v0.0.0-...-0c7c43c Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2019 License: GPL-3.0 Imports: 3 Imported by: 5

Documentation

Overview

Package common provides complimentary types and methods that are available to other modules as a direct import, e.g:

import "github.com/go-comply/comply/common"

This is the ONLY package directory (inside of the comply suite) that contributor modules (e.g: RFC1034) may import.

This package folder exists merely to allow contributors to avoid writing their own basic character parsers. Though its use is encouraged, it is not required.

Index

Constants

View Source
const (
	// ForwardSlash rune (decimal 47, Solidus)
	ForwardSlash = forwardSlash

	// Underscore rune (decimal 95, Low line)
	Underscore = underscore

	// Hyphen rune (decimal 45)
	Hyphen = hyphen

	// Colon rune (decimal 58)
	Colon = colon

	// Period rune (decimal 46, Full Stop)
	Period = period
)

Miscellaneous rune constants

View Source
const (

	// ImperativeMust represents the Must/Required/Shall imperatives described in RFC 2119.
	ImperativeMust uint = iota // 0x0 or 0

	// ImperativeMustNot represents the MustNot/ShallNot imperatives described in RFC 2119.
	ImperativeMustNot // 0x1 or 1

	// ImperativeShould represents the Should/Recommended imperatives described RFC 2119.
	ImperativeShould // 0x2 or 2

	// ImperativeShouldNot represents the ShouldNot/NotRecommended imperatives described RFC 2119.
	ImperativeShouldNot // 0x3 or 3

	// ImperativeMay represents the May/Optional imperatives described in RFC 2119.
	ImperativeMay // 0x4 or 4

	// ImperativeRequired is a deprecated alias for ImperativeMust. Use of ImperativeMust is preferred.
	ImperativeRequired = ImperativeMust

	// ImperativeShall is a deprecated alias for ImperativeMust. Use of ImperativeMust is preferred.
	ImperativeShall = ImperativeMust

	// ImperativeShallNot is a deprecated alias for ImperativeMustNot. Use of ImperativeMustNot is preferred.
	ImperativeShallNot = ImperativeMustNot

	// ImperativeRecommended is a deprecated alias for ImperativeShould. Use of ImperativeShould is preferred.
	ImperativeRecommended = ImperativeShould

	// ImperativeNotRecommended is a deprecated alias for ImperativeShouldNot. Use of ImperativeShouldNot is preferred.
	ImperativeNotRecommended = ImperativeShouldNot

	// ImperativeOptional is a deprecated alias for ImperativeMay. Use of ImperativeMay is preferred.
	ImperativeOptional = ImperativeMay
)
View Source
const NullTerminator = null

NullTerminator describes the null-length ASCII non-printing character (decimal 0), which is expressed as '\x00' in rune form.

View Source
const (
	UrlPrefix = `https://tools.ietf.org/html/`
)

UrlPrefix is the prefix of any URL returned to the user when a request for more information is executed. The `rfcXXXX` string would be appended on the right.

Variables

This section is empty.

Functions

func Debug

func Debug(b bool)

Debug will allow a boolean toggle declaring whether extended debug output should be printed to Stdout.

func FallsWithin

func FallsWithin(ranges ...interface{}) bool

FallsWithin returns a boolean indicative of whether or not the specified length (cur) falls within the minimum (min) and maximum (max) length boundaries.

func FileExists

func FileExists(p string) bool

FileExists returns a bool indicative of the presence of the named file.

func FitsU16

func FitsU16(i interface{}) bool

FitsU16 will determine if an integer or uint will fit into a uint16. This evaluation will be failed if the value is 0 in any type case.

func Id

func Id(ii interface{}) (ri rfcId)

Id (pertaining to an RFC's numerical ID) will cast either a positive int or a non-zero uint to the necessary uint16 type.

Note that a return of uint16(0) indicates a problem (either the int or uint was too large to be accommodated by a uint16 type, or it was a negative int).

func ImperativeValid

func ImperativeValid(i int) bool

ImperativeValid shall determine whether the given integer (i) is valid when representing an RFC 2119 Imperative (which is also numerical). A bool of true is returned if valid, false otherwise.

func Ints2Sec

func Ints2Sec(sec ...int) rfcSection

Ints2Sec accepts a non-zero array of integer types ([]int) that, in sequence, are alleged to represent an RFC section (e.g: 2.1.4.10). Each int element in the array is evaluated to ensure it is greater than zero (as RFC section levels can never be zero), and if so, is cast as a string into a string array ([]string). This string array is then joined via period delimiters (".") and returned, cast as an instance of rfcSection. If there was an error, an empty instance of the same type.

This method is the integer-input version of the str2sec method. Each produces the same ultimate result.

func IsASCII

func IsASCII(r rune) bool

IsASCII returns a bool indicative of whether the rune (r) complies with the entire US ASCII / ANSI X3.4-1986 (ISO-646) character range standard, including non-printable characters 0-31 and 127.

See http://www.columbia.edu/kermit/ascii.html for a helpful table of these characters.

func IsAlnum

func IsAlnum(ch rune) bool

IsAlnum returns a bool indicative of whether or not a character (ch) an ASCII alphabetical character of any case, OR a number.

func IsAlpha

func IsAlpha(ch rune) bool

IsAlpha returns a bool indicative of whether or not a character (ch) an ASCII alphabetical character of any case.

func IsColon

func IsColon(ch rune) bool

IsColon returns a bool indicative of whether or not a character (ch) is an ASCII colon character.

func IsDigit

func IsDigit(ch rune) bool

IsDigit returns a bool indicative of whether or not a character (ch) is a number.

func IsForwardSlash

func IsForwardSlash(ch rune) bool

IsForwardSlash returns a bool indicative of whether or not a character (ch) is a forward-slash ("/") ASCII character.

func IsHyphen

func IsHyphen(ch rune) bool

IsHyphen returns a bool indicative of whether or not a character (ch) is an ASCII hyphen (a.k.a "dash") character.

func IsLower

func IsLower(ch rune) bool

IsLower returns a bool indicative of whether or not a character (ch) an ASCII lowercase alphabetical character.

func IsPeriod

func IsPeriod(ch rune) bool

IsPeriod returns a bool indicative of whether or not a character (ch) is an ASCII period (a.k.a "dot") character.

func IsPrintableASCII

func IsPrintableASCII(r rune) bool

IsPrintableASCII returns a bool indicative of whether the rune (r) complies with the US ASCII / ANSI X3.4-1986 (ISO-646) PRINTABLE character range standard (characters 32 through 126). This excludes non-printing characters 0-31 and 127.

See http://www.columbia.edu/kermit/ascii.html for a helpful table of these characters.

func IsUnderscore

func IsUnderscore(ch rune) bool

IsUnderscore returns a bool indicative of whether or not a character (ch) is an ASCII underscore character.

func IsUpper

func IsUpper(ch rune) bool

IsUpper returns a bool indicative of whether or not a character (ch) an ASCII uppercase alphabetical character.

func Itoa

func Itoa(i interface{}) string

Itoa is merely a cheap strconv.itoa substitute

func Raise

func Raise(s string, m ...interface{})

Raise will just PRINT the string form of the input (meant for debug output, as newlines are inserted). Note there is no return ...

func RaiseBadCodec

func RaiseBadCodec(s string, m ...interface{}) error

RaiseBadCodec will raise a general Codec error

func RaiseBadExe

func RaiseBadExe(s string, m ...interface{}) error

RaiseBadExe will raise an error regarding a bad attempted compliance check execution.

func RaiseBadImp

func RaiseBadImp(s string, m ...interface{}) error

RaiseBadImp will raise an error regarding use of an invalid RFC 2119 Imperative.

func RaiseBadImpIdx

func RaiseBadImpIdx(s string, m ...interface{}) error

RaiseBadImpIdx will raise an error regarding bad imperative index instance

func RaiseBadLen

func RaiseBadLen(s string, m ...interface{}) error

RaiseBadLen will raise an error regarding a bad or incongruent length.

func RaiseBadParam

func RaiseBadParam(s string, m ...interface{}) error

RaiseBadParam will raise a general parameter/input error

func RaiseBadRfcNum

func RaiseBadRfcNum(s string, m ...interface{}) error

RaiseBadRfcNum will raise an error regarding bad RFC numbers

func RaiseBadSec

func RaiseBadSec(s string, m ...interface{}) error

RaiseBadSec will raise an error regarding bad section data

func RaiseBadSyn

func RaiseBadSyn(s string, m ...interface{}) error

RaiseBadSyn will raise a non-compliance error based on syntax violation

func RaiseBadType

func RaiseBadType(s string, m ...interface{}) error

RaiseBadType will raise an error regarding bad type

func RaiseByteOver

func RaiseByteOver(s string, m ...interface{}) error

RaiseByteOver will raise a non-compliance error based on a byte overflow (length)

func RaiseGeneric

func RaiseGeneric(s string, m ...interface{}) error

RaiseGeneric will raise a general error

func RaiseIOErr

func RaiseIOErr(s string, m ...interface{}) error

RaiseIOErr will raise an error regarding bad IO events (e.g: nonexistent file)

func RaiseIdentAdj

func RaiseIdentAdj(s string, m ...interface{}) error

RaiseIdentAdj will raise an identical adjacent brother error

func RaiseNilReg

func RaiseNilReg(s string, m ...interface{}) error

RaiseNilReg will raise an error regarding a bad registration attempt

func RaiseNilVal

func RaiseNilVal(s string, m ...interface{}) error

RaiseNilVal will raise an error if a null or zero value is encountered

func RaiseNonComp

func RaiseNonComp(s string, m ...interface{}) error

RaiseNonComp will raise a non-compliance error (general)

func RaiseNullByte

func RaiseNullByte(s string, m ...interface{}) error

RaiseNullByte will raise a non-compliance error based on a null byte or sequence inappropriately placed

func RaiseOutOfBounds

func RaiseOutOfBounds(s string, m ...interface{}) error

RaiseOutOfBounds will raise a non-compliance error (general)

func Sec2Str

func Sec2Str(sec ...int) string

Sec2Str will fashion a string RFC section notation in the form of integers that are delimited by dots (".") with no reasonable length limited predefined. Said integers must always be >= 1 and must correspond (in sequence) to an actual section in said RFC.

func Section

func Section(ss interface{}) (sec rfcSection)

Section shall convert any of:

  • string
  • []int

... to a proper RFC section ID value (e.g: []{2,1,4,10} would become 2.1.4.10).

This is useful during executions of compliance checks belonging to any number of RFC modules.

func Str2Sec

func Str2Sec(sec string) rfcSection

Str2Sec deconstructs a section string (e.g: 2.1.4.10) by splitting each string element per the period (".") delimiter. Each element is then parsed one character at a time to ensure we're dealing with digits only. If nothing violates this process, an identical (but reconstructed) string is returned, cast as the rfcSection type. This method is the string-input version of the ints2sec method. Each produces the same ultimate result.

func StrIsDigit

func StrIsDigit(str interface{}) bool

StrIsDigit determines if one or more strings (string or []string) contains characters other than digits 0-9. If only digits are detected, return true else false.

Types

This section is empty.

Jump to

Keyboard shortcuts

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