github.com/wata727/tflint@v0.12.2-0.20191013070026-96dd0d36f385/langserver/conn.go (about) 1 package langserver 2 3 import "io" 4 5 // Conn is a connection for LSP 6 type Conn struct { 7 reader io.ReadCloser 8 writer io.WriteCloser 9 } 10 11 // NewConn returns a new LSP connection 12 func NewConn(reader io.ReadCloser, writer io.WriteCloser) *Conn { 13 return &Conn{ 14 reader: reader, 15 writer: writer, 16 } 17 } 18 19 // Read reads data from input 20 func (c *Conn) Read(p []byte) (int, error) { 21 return c.reader.Read(p) 22 } 23 24 // Write writes data to output 25 func (c *Conn) Write(p []byte) (int, error) { 26 return c.writer.Write(p) 27 } 28 29 // Close closes the connection 30 func (c *Conn) Close() error { 31 if err := c.reader.Close(); err != nil { 32 return err 33 } 34 return c.writer.Close() 35 }