buidlctl: upon error add line number in addition to filename

Signed-off-by: Tibor Vass <tibor@docker.com>
v0.8
Tibor Vass 2020-04-29 20:37:05 +00:00
parent 365a58177e
commit da4e440dbd
1 changed files with 3 additions and 2 deletions

View File

@ -1,7 +1,7 @@
package errdefs package errdefs
import ( import (
fmt "fmt" "fmt"
"io" "io"
"strings" "strings"
@ -63,6 +63,7 @@ func (s *Source) Print(w io.Writer) error {
} }
var p int var p int
prepadStart := start
for { for {
if p >= pad { if p >= pad {
break break
@ -78,7 +79,7 @@ func (s *Source) Print(w io.Writer) error {
p++ p++
} }
fmt.Fprintf(w, "%s\n--------------------\n", s.Filename) fmt.Fprintf(w, "%s:%d\n--------------------\n", s.Filename, prepadStart)
for i := start; i <= end; i++ { for i := start; i <= end; i++ {
pfx := " " pfx := " "
if containsLine(s.Locations, i) { if containsLine(s.Locations, i) {