func (e *parseError) Error() string {
	return fmt.Sprintf("failed to parse '%s' directive with args '%s': %s",
		strings.ToUpper(e.t), e.args, e.msg)
}
Error returns a formatted error string.
package dockerfile
import (
	"encoding/json"
	"errors"
	"fmt"
	"strings"
	"unicode"
)
var (
	errBeforeFirstFrom      = errors.New("Invalid directive before first build stage (FROM)")
	errMalformedChown       = errors.New("Malformed chown argument")
	errMalformedKeyVal      = errors.New("Malformed key/value pairs")
	errMissingArgs          = errors.New("Missing arguments")
	errMissingSpace         = errors.New("Missing space in single variable ENV")
	errNotExactlyOneArg     = errors.New("Expected exactly one argument")
	errUnsupportedDirective = errors.New("Unsupported directive type")
)
func parseBoolFlag(s string, name string) error {
	flag := "--" + name
	if !strings.EqualFold(s, flag) {
		return fmt.Errorf("Wrong flag format for %s", flag)
	}
	return nil
}
func parseStringFlag(s string, name string) (string, bool, error) {
	flag := "--" + name + "="
	if !strings.HasPrefix(s, flag) {
		return "", false, nil
	}
	if len(s) == len(flag) {
		return "", false, fmt.Errorf("Missing value for flag: %s", name)
	}
	return s[len(flag):], true, nil
}
func parseJSONArray(s string) (l []string, ok bool) {
	err := json.NewDecoder(strings.NewReader(s)).Decode(&l)
	return l, err == nil
}
func validKeyRune(r rune) error {
	if unicode.IsLetter(r) || unicode.IsNumber(r) || r == '-' || r == '_' || r == '.' {
		return nil
	}
	return fmt.Errorf("invalid character in variable key: %s", string(r))
}
type parseError struct {
	t    string
	args string
	msg  string
}