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
- func Debug(b bool)
- func FallsWithin(ranges ...interface{}) bool
- func FileExists(p string) bool
- func FitsU16(i interface{}) bool
- func Id(ii interface{}) (ri rfcId)
- func ImperativeValid(i int) bool
- func Ints2Sec(sec ...int) rfcSection
- func IsASCII(r rune) bool
- func IsAlnum(ch rune) bool
- func IsAlpha(ch rune) bool
- func IsColon(ch rune) bool
- func IsDigit(ch rune) bool
- func IsForwardSlash(ch rune) bool
- func IsHyphen(ch rune) bool
- func IsLower(ch rune) bool
- func IsPeriod(ch rune) bool
- func IsPrintableASCII(r rune) bool
- func IsUnderscore(ch rune) bool
- func IsUpper(ch rune) bool
- func Itoa(i interface{}) string
- func Raise(s string, m ...interface{})
- func RaiseBadCodec(s string, m ...interface{}) error
- func RaiseBadExe(s string, m ...interface{}) error
- func RaiseBadImp(s string, m ...interface{}) error
- func RaiseBadImpIdx(s string, m ...interface{}) error
- func RaiseBadLen(s string, m ...interface{}) error
- func RaiseBadParam(s string, m ...interface{}) error
- func RaiseBadRfcNum(s string, m ...interface{}) error
- func RaiseBadSec(s string, m ...interface{}) error
- func RaiseBadSyn(s string, m ...interface{}) error
- func RaiseBadType(s string, m ...interface{}) error
- func RaiseByteOver(s string, m ...interface{}) error
- func RaiseGeneric(s string, m ...interface{}) error
- func RaiseIOErr(s string, m ...interface{}) error
- func RaiseIdentAdj(s string, m ...interface{}) error
- func RaiseNilReg(s string, m ...interface{}) error
- func RaiseNilVal(s string, m ...interface{}) error
- func RaiseNonComp(s string, m ...interface{}) error
- func RaiseNullByte(s string, m ...interface{}) error
- func RaiseOutOfBounds(s string, m ...interface{}) error
- func Sec2Str(sec ...int) string
- func Section(ss interface{}) (sec rfcSection)
- func Str2Sec(sec string) rfcSection
- func StrIsDigit(str interface{}) bool
Constants ¶
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
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 )
const NullTerminator = null
NullTerminator describes the null-length ASCII non-printing character (decimal 0), which is expressed as '\x00' in rune form.
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 ¶
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 ¶
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 ¶
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 ¶
IsAlnum returns a bool indicative of whether or not a character (ch) an ASCII alphabetical character of any case, OR a number.
func IsAlpha ¶
IsAlpha returns a bool indicative of whether or not a character (ch) an ASCII alphabetical character of any case.
func IsColon ¶
IsColon returns a bool indicative of whether or not a character (ch) is an ASCII colon character.
func IsForwardSlash ¶
IsForwardSlash returns a bool indicative of whether or not a character (ch) is a forward-slash ("/") ASCII character.
func IsHyphen ¶
IsHyphen returns a bool indicative of whether or not a character (ch) is an ASCII hyphen (a.k.a "dash") character.
func IsLower ¶
IsLower returns a bool indicative of whether or not a character (ch) an ASCII lowercase alphabetical character.
func IsPeriod ¶
IsPeriod returns a bool indicative of whether or not a character (ch) is an ASCII period (a.k.a "dot") character.
func IsPrintableASCII ¶
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 ¶
IsUnderscore returns a bool indicative of whether or not a character (ch) is an ASCII underscore character.
func IsUpper ¶
IsUpper returns a bool indicative of whether or not a character (ch) an ASCII uppercase alphabetical character.
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 ¶
RaiseBadCodec will raise a general Codec error
func RaiseBadExe ¶
RaiseBadExe will raise an error regarding a bad attempted compliance check execution.
func RaiseBadImp ¶
RaiseBadImp will raise an error regarding use of an invalid RFC 2119 Imperative.
func RaiseBadImpIdx ¶
RaiseBadImpIdx will raise an error regarding bad imperative index instance
func RaiseBadLen ¶
RaiseBadLen will raise an error regarding a bad or incongruent length.
func RaiseBadParam ¶
RaiseBadParam will raise a general parameter/input error
func RaiseBadRfcNum ¶
RaiseBadRfcNum will raise an error regarding bad RFC numbers
func RaiseBadSec ¶
RaiseBadSec will raise an error regarding bad section data
func RaiseBadSyn ¶
RaiseBadSyn will raise a non-compliance error based on syntax violation
func RaiseBadType ¶
RaiseBadType will raise an error regarding bad type
func RaiseByteOver ¶
RaiseByteOver will raise a non-compliance error based on a byte overflow (length)
func RaiseGeneric ¶
RaiseGeneric will raise a general error
func RaiseIOErr ¶
RaiseIOErr will raise an error regarding bad IO events (e.g: nonexistent file)
func RaiseIdentAdj ¶
RaiseIdentAdj will raise an identical adjacent brother error
func RaiseNilReg ¶
RaiseNilReg will raise an error regarding a bad registration attempt
func RaiseNilVal ¶
RaiseNilVal will raise an error if a null or zero value is encountered
func RaiseNonComp ¶
RaiseNonComp will raise a non-compliance error (general)
func RaiseNullByte ¶
RaiseNullByte will raise a non-compliance error based on a null byte or sequence inappropriately placed
func RaiseOutOfBounds ¶
RaiseOutOfBounds will raise a non-compliance error (general)
func Sec2Str ¶
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.