-
-
Notifications
You must be signed in to change notification settings - Fork 83
/
Copy pathmarker.go
33 lines (27 loc) · 787 Bytes
/
marker.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Package check checks provided Go code and reports syntax errors
package check
import (
"go/scanner"
"github.com/x1unix/go-playground/pkg/monaco"
)
func errorsListToMarkers(errList scanner.ErrorList) []monaco.MarkerData {
markers := make([]monaco.MarkerData, 0, len(errList))
for _, err := range errList {
markers = append(markers, monaco.MarkerData{
Severity: monaco.Error,
Message: err.Msg,
StartLineNumber: err.Pos.Line,
EndLineNumber: err.Pos.Line,
StartColumn: err.Pos.Column - 1,
EndColumn: err.Pos.Column,
})
}
return markers
}
// Result is result
type Result struct {
// HasErrors is error status
HasErrors bool `json:"hasErrors"`
// Markers is list of marker data
Markers []monaco.MarkerData `json:"markers"`
}