Files
go-semantic-release/vendor/github.com/davidmz/go-pageant/io_windows.go
Aaron Guise ff1798b10b
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
fix(*): Vendored project dependencies
2024-04-08 14:00:37 +12:00

43 lines
629 B
Go

package pageant
import (
"io"
"sync"
"golang.org/x/crypto/ssh/agent"
)
// New returns new ssh-agent instance (see http://golang.org/x/crypto/ssh/agent)
func New() agent.Agent {
return agent.NewClient(&conn{})
}
type conn struct {
sync.Mutex
buf []byte
}
func (c *conn) Write(p []byte) (int, error) {
c.Lock()
defer c.Unlock()
resp, err := query(p)
if err != nil {
return 0, err
}
c.buf = append(c.buf, resp...)
return len(p), nil
}
func (c *conn) Read(p []byte) (int, error) {
c.Lock()
defer c.Unlock()
if len(c.buf) == 0 {
return 0, io.EOF
}
n := copy(p, c.buf)
c.buf = c.buf[n:]
return n, nil
}