-
Notifications
You must be signed in to change notification settings - Fork 20
/
main.go
54 lines (38 loc) · 1.1 KB
/
main.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package main
import (
"context"
"flag"
"os"
"github.com/sourcegraph/jsonrpc2"
)
var defaultSeverity = "Warn"
func main() {
debug := flag.Bool("debug", false, "output debug log")
noLinterName := flag.Bool("nolintername", false, "don't show a linter name in message")
flag.StringVar(&defaultSeverity, "severity", defaultSeverity, "Default severity to use. Choices are: Err(or), Warn(ing), Info(rmation) or Hint")
flag.Parse()
logger := newStdLogger(*debug)
handler := NewHandler(logger, *noLinterName)
var connOpt []jsonrpc2.ConnOpt
logger.Printf("golangci-lint-langserver: connections opened")
<-jsonrpc2.NewConn(
context.Background(),
jsonrpc2.NewBufferedStream(stdrwc{}, jsonrpc2.VSCodeObjectCodec{}),
handler,
connOpt...,
).DisconnectNotify()
logger.Printf("golangci-lint-langserver: connections closed")
}
type stdrwc struct{}
func (stdrwc) Read(p []byte) (int, error) {
return os.Stdin.Read(p)
}
func (stdrwc) Write(p []byte) (int, error) {
return os.Stdout.Write(p)
}
func (stdrwc) Close() error {
if err := os.Stdin.Close(); err != nil {
return err
}
return os.Stdout.Close()
}