v.io: v.io/x/ref/lib/vdl/vdlutil Index | Files

package vdlutil

import "v.io/x/ref/lib/vdl/vdlutil"

Package vdlutil implements utilities used by many VDL components. It should have a small set of dependencies.


Package Files

errors.go util.go vlog.go


var (
    // Vlog is a logger that discards output by default, and only outputs real
    // logs when SetVerbose is called.
    Vlog = log.New(ioutil.Discard, logPrefix, logFlags)

func FirstRuneToExportCase Uses

func FirstRuneToExportCase(s string, export bool) string

FirstRuneToExportCase returns s with its first rune in uppercase if export is true, otherwise in lowercase.

func FirstRuneToLower Uses

func FirstRuneToLower(s string) string

FirstRuneToLower returns s with its first rune in lowercase.

func FirstRuneToUpper Uses

func FirstRuneToUpper(s string) string

FirstRuneToUpper returns s with its first rune in uppercase.

func SetVerbose Uses

func SetVerbose()

SetVerbose tells the vdl package (and subpackages) to enable verbose logging.

func ToConstCase Uses

func ToConstCase(s string) string

toConstCase converts ThisString to THIS_STRING. For adding '_', we follow the following algorithm. For any sequence of three characters, c[n-1], c[n], c[n+1], we add an underscore before c[n] if:

1) c[n-1] is a digit and c[n] is a letter, or
2) c[n-1] is a letter and c[n] is a digit, or
3) c[n-1] is lowercase, and c[n] is uppercase, or
4) c[n-1] is uppercase, c[n] is uppercase, and c[n+1] is lowercase.

type Errors Uses

type Errors struct {
    MaxErrors int
    // contains filtered or unexported fields

Errors holds a buffer of encountered errors. The point is to try displaying all errors to the user rather than just the first. We cutoff at MaxErrors to ensure if something's really messed up we won't spew errors forever. Set MaxErrors=-1 to effectively continue despite any number of errors. The zero Errors struct stops at the first error encountered.

func NewErrors Uses

func NewErrors(max int) *Errors

NewErrors returns a new Errors object, holding up to max errors.

func (*Errors) Error Uses

func (e *Errors) Error(msg string) bool

Error adds the error described by msg to the buffer. Returns true iff we're still under the MaxErrors cutoff.

func (*Errors) Errorf Uses

func (e *Errors) Errorf(format string, v ...interface{}) bool

Errorf is like Error, and takes the same args as fmt.Printf.

func (*Errors) IsEmpty Uses

func (e *Errors) IsEmpty() bool

IsEmpty returns true iff there weren't any errors.

func (*Errors) IsFull Uses

func (e *Errors) IsFull() bool

IsFull returns true iff we hit the MaxErrors cutoff.

func (*Errors) NumErrors Uses

func (e *Errors) NumErrors() int

NumErrors returns the number of errors we've seen.

func (*Errors) Reset Uses

func (e *Errors) Reset()

Reset clears the internal state so you start with no buffered errors. MaxErrors remains the same; if you want to change it you should create a new Errors struct.

func (*Errors) String Uses

func (e *Errors) String() string

String returns the buffered errors as a single human-readable string.

func (*Errors) ToError Uses

func (e *Errors) ToError() error

ToError returns the buffered errors as a single error, or nil if there weren't any errors.

Package vdlutil imports 9 packages (graph) and is imported by 18 packages. Updated 2018-08-27. Refresh now. Tools for package owners.