Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
tmp
.idea
.idea
go.sum
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# go-console

[![Main](https://github.com/runletapp/go-console/actions/workflows/main.yml/badge.svg)](https://github.com/runletapp/go-console/actions/workflows/main.yml)
[![GoDoc](https://godoc.org/github.com/runletapp/go-console?status.svg)](https://godoc.org/github.com/runletapp/go-console)
[![Main](https://github.com/jm33-m0/go-console/actions/workflows/main.yml/badge.svg)](https://github.com/jm33-m0/go-console/actions/workflows/main.yml)
[![GoDoc](https://godoc.org/github.com/jm33-m0/go-console?status.svg)](https://godoc.org/github.com/jm33-m0/go-console)

`go-console` is a cross-platform `PTY` interface. On *nix platforms we rely on [pty](github.com/creack/pty) and on windows [go-winpty](https://github.com/iamacarpet/go-winpty) (go-console will ship [winpty-0.4.3-msvc2015](https://github.com/rprichard/winpty/releases/tag/0.4.3) using `go:embed`, so there's no need to include winpty binaries)

Expand All @@ -17,7 +17,7 @@ import (
"runtime"
"sync"

"github.com/runletapp/go-console"
"github.com/jm33-m0/go-console"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion console.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package console

import (
"github.com/runletapp/go-console/interfaces"
"github.com/jm33-m0/go-console/interfaces"
)

// Console communication interface
Expand Down
2 changes: 1 addition & 1 deletion console_nix.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/creack/pty"

"github.com/runletapp/go-console/interfaces"
"github.com/jm33-m0/go-console/interfaces"
)

var _ interfaces.Console = (*consoleNix)(nil)
Expand Down
18 changes: 10 additions & 8 deletions console_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
//go:build !arm64
// +build !arm64

package console

import (
"bytes"
"fmt"
"io"
"io/ioutil"
"os"
"path"
"runtime"
Expand Down Expand Up @@ -41,7 +43,7 @@ func checkSnapshot(t *testing.T, name string, data []byte) {
}
defer file.Close()

snapshotData, err := ioutil.ReadAll(file)
snapshotData, err := io.ReadAll(file)
assert.Nil(err)

assert.EqualValues(snapshotData, data)
Expand All @@ -64,7 +66,7 @@ func TestRun(t *testing.T) {
assert.Nil(err)
defer proc.Close()

data, _ := ioutil.ReadAll(proc)
data, _ := io.ReadAll(proc)

if runtime.GOOS == "windows" {
assert.Truef(bytes.Contains(data, []byte("windows")), "Does not contain output")
Expand All @@ -87,7 +89,7 @@ func TestSize(t *testing.T) {

assert.Nil(proc.Start(args))

data, _ := ioutil.ReadAll(proc)
data, _ := io.ReadAll(proc)

os.Stdout.Write(data)

Expand All @@ -111,7 +113,7 @@ func TestSize2(t *testing.T) {

assert.Nil(proc.Start(args))

data, _ := ioutil.ReadAll(proc)
data, _ := io.ReadAll(proc)
os.Stdout.Write(data)

if runtime.GOOS == "windows" {
Expand Down Expand Up @@ -166,15 +168,15 @@ func TestCWD(t *testing.T) {
assert.Nil(err)
defer proc.Close()

tmpdir, err := ioutil.TempDir("", "go-console_")
tmpdir, err := os.MkdirTemp("", "go-console_")
assert.Nil(err)
defer os.RemoveAll(tmpdir)

assert.Nil(proc.SetCWD(tmpdir))

assert.Nil(proc.Start(args))

data, _ := ioutil.ReadAll(proc)
data, _ := io.ReadAll(proc)

assert.Contains(string(data), tmpdir)
}
Expand All @@ -195,7 +197,7 @@ func TestENV(t *testing.T) {

assert.Nil(proc.Start(args))

data, _ := ioutil.ReadAll(proc)
data, _ := io.ReadAll(proc)

assert.Contains(string(data), "MYENV=test")
}
Expand Down
13 changes: 8 additions & 5 deletions console_windows.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
//go:build amd64
// +build amd64

package console

import (
"embed"
"fmt"
"io/ioutil"
"os"
"path"
"path/filepath"
"runtime"
"strings"
"syscall"

"github.com/iamacarpet/go-winpty"
"github.com/runletapp/go-console/interfaces"
"github.com/jm33-m0/go-console/interfaces"
)

// Do the interface allocations only once for common
Expand All @@ -24,7 +27,7 @@ var (
errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING)
)

//go:embed winpty/*
//go:embed winpty/amd64/*
var winpty_deps embed.FS

// errnoErr returns common boxed Errno values, to prevent
Expand Down Expand Up @@ -106,7 +109,7 @@ func (c *consoleWindows) UnloadEmbeddedDeps() (string, error) {

files := []string{"winpty.dll", "winpty-agent.exe"}
for _, file := range files {
filenameEmbedded := fmt.Sprintf("winpty/%s", file)
filenameEmbedded := fmt.Sprintf("winpty/%s/%s", runtime.GOARCH, file)
filenameDisk := path.Join(dllDir, file)

_, statErr := os.Stat(filenameDisk)
Expand All @@ -120,7 +123,7 @@ func (c *consoleWindows) UnloadEmbeddedDeps() (string, error) {
return "", err
}

if err := ioutil.WriteFile(path.Join(dllDir, file), data, 0644); err != nil {
if err := os.WriteFile(path.Join(dllDir, file), data, 0644); err != nil {
return "", err
}
}
Expand Down
Loading