mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-24 01:08:10 +02:00
Use the io.Reader interface
This commit is contained in:
19
tools/utils/io.go
Normal file
19
tools/utils/io.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"io"
|
||||
)
|
||||
|
||||
type BytesReader struct {
|
||||
Data []byte
|
||||
Pos int64
|
||||
}
|
||||
|
||||
func (self *BytesReader) Read(b []byte) (n int, err error) {
|
||||
if self.Pos >= int64(len(self.Data)) {
|
||||
return 0, io.EOF
|
||||
}
|
||||
n = copy(b, self.Data[self.Pos:])
|
||||
self.Pos += int64(n)
|
||||
return
|
||||
}
|
||||
@@ -2,9 +2,10 @@ package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/seancfoley/ipaddress-go/ipaddr"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/seancfoley/ipaddress-go/ipaddr"
|
||||
)
|
||||
|
||||
func Cut(s string, sep string) (string, string, bool) {
|
||||
@@ -21,7 +22,7 @@ func ParseSocketAddress(spec string) (network string, addr string, err error) {
|
||||
return
|
||||
}
|
||||
if network == "unix" {
|
||||
if strings.HasSuffix(addr, "@") && runtime.GOOS != "linux" {
|
||||
if strings.HasPrefix(addr, "@") && runtime.GOOS != "linux" {
|
||||
err = fmt.Errorf("Abstract UNIX sockets are only supported on Linux. Cannot use: %s", spec)
|
||||
}
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user