// errorf adds formatted error information to err.
// It may be called multiple times to provide additional information.
func (err *error_) errorf(at poser, format string, args ...interface{}) {
- err.desc = append(err.desc, errorDesc{posFor(at), format, args})
+ err.desc = append(err.desc, errorDesc{atPos(at), format, args})
}
func sprintf(qf Qualifier, tpSubscripts bool, format string, args ...interface{}) string {
return
}
- pos := posFor(at)
+ pos := atPos(at)
// If we are encountering an error while evaluating an inherited
// constant initialization expression, pos is the position of in
pos = check.errpos
}
- err := Error{pos, stripAnnotations(msg), msg, soft}
+ // If we have a URL for error codes, add a link to the first line.
+ if code != 0 && check.conf.ErrorURL != "" {
+ u := fmt.Sprintf(check.conf.ErrorURL, code)
+ if i := strings.Index(msg, "\n"); i >= 0 {
+ msg = msg[:i] + u + msg[i:]
+ } else {
+ msg += u
+ }
+ }
+
+ err := Error{pos, stripAnnotations(msg), msg, soft, code}
if check.firstErr == nil {
check.firstErr = err
}
check.err(at, code, check.sprintf(format, args...), true)
}
-func (check *Checker) versionErrorf(at poser, goVersion string, format string, args ...interface{}) {
+func (check *Checker) versionErrorf(at poser, v goVersion, format string, args ...interface{}) {
msg := check.sprintf(format, args...)
- msg = fmt.Sprintf("%s requires %s or later", msg, goVersion)
+ msg = fmt.Sprintf("%s requires %s or later", msg, v)
check.err(at, UnsupportedFeature, msg, true)
}
-// posFor reports the left (= start) position of at.
-func posFor(at poser) syntax.Pos {
+// atPos reports the left (= start) position of at.
+func atPos(at poser) syntax.Pos {
switch x := at.(type) {
case *operand:
if x.expr != nil {