Categorygithub.com/admpub/gopty
modulepackage
0.1.2
Repository: https://github.com/admpub/gopty.git
Documentation: pkg.go.dev

# README

gopty

GoDoc

gopty is a cross-platform PTY interface. On *nix platforms we rely on pty and on windows go-winpty (gopty will ship winpty-0.4.3-msvc2015 using go:embed, so there's no need to include winpty binaries)

Example

package main

import (
	"io"
	"log"
	"os"
	"runtime"
	"sync"

	"github.com/admpub/gopty"
)

func main() {

	proc, err := gopty.New(120, 60)
	if err != nil {
		panic(err)
	}
	defer proc.Close()

	var args []string

	if runtime.GOOS == "windows" {
		args = []string{"cmd.exe", "/c", "dir"}
	} else {
		args = []string{"ls", "-lah", "--color"}
	}

	if err := proc.Start(args); err != nil {
		panic(err)
	}

	var wg sync.WaitGroup
	wg.Add(1)
	go func() {
		defer wg.Done()

		_, err = io.Copy(os.Stdout, proc)
		if err != nil {
			log.Printf("Error: %v\n", err)
		}
	}()

	if _, err := proc.Wait(); err != nil {
		log.Printf("Wait err: %v\n", err)
	}

	wg.Wait()
}

# Packages

No description provided by the author
No description provided by the author

# Functions

Execute execute command.
GetBash get bash file.
GetFlagVar bash flag variable name.
No description provided by the author
New creates a new console with initial size.
PTY2Websocket pty to websocket.
ServeWebsocket ServeWebsocket(wsc,120,60).
Websocket2PTY websocket to pty.

# Constants

BinaryMessage denotes a binary data message.
CloseMessage denotes a close control message.
PingMessage denotes a ping control message.
PongMessage denotes a pong control message.
TextMessage denotes a text data message.

# Variables

No description provided by the author
No description provided by the author

# Interfaces

Websocketer websocket interface github.com/admpub/websocket github.com/gorilla/websocket.
WebsocketReader websocket reader.
WebsocketWriter websocket writer.

# Type aliases

Console communication interface.