Git Product home page Git Product logo

goterm's Introduction

CircleCI

The term package implements PTY creation and termios get/set attributes. It also contains some convenience functions for colors, SSH <> termios translations, readCh , reading passwords etc.

The PTY and termios parts are Linux specific.

Get the code

go get github.com/google/goterm/term

package main

import (
  "fmt"

  "github.com/google/goterm/term"
)

func main() {
  fmt.Println(term.Blue("Hello blue world"))
}

goterm's People

Contributors

marco-m avatar olakargo avatar skalle avatar zouguangxian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

goterm's Issues

OpenPTY fails on ppc64le and s390x

When building goterm for ppc64le and s390x on Linux, the OpenPTY calls fail:

github.com/google/goterm/term
--- FAIL: TestClose (0.00s)
    termios_test.go:92: OpenPTY failed: open /dev/pts/4294967296: no such file or directory
--- FAIL: TestGetPass (0.00s)
    termios_test.go:138: OpenPTY() failed: open /dev/pts/4294967296: no such file or directory
--- FAIL: TestGetChar (0.00s)
    termios_test.go:199: OpenPTY failed: open /dev/pts/4294967296: no such file or directory
FAIL
exit status 1
FAIL	github.com/google/goterm/term	0.057s

You can find the full logs at https://koji.fedoraproject.org/koji/taskinfo?taskID=70436491 and https://koji.fedoraproject.org/koji/taskinfo?taskID=70436492 (look at build.log)

Refactoring PTY creation to allow support for other platforms

I have a variation on OpenPTY that is Darwin specific. It even works for both Sierra and High Sierra. For my own use, I can live with the goterm project being in a vendor directory and using it on Linux, Darwin and soon OpenBSD platforms. But the work to support Darwin was non-trivial and I'd like to share it but I don't see how without cloning the entire goterm repo. But cloning goterm means projects like goexpect wouldn't get the new options without also having been cloned for a one line import change.

The ExampleColor test is failing.

I'm sure this worked at some stage ...

--- FAIL: ExampleColor (0.00s)
got:
Hello Green world
Warning!
Green world
Defcon: 2 FAST PACE
want:
Hello [32mGreen world[39m
[31mWarning![39m
[5mGreen world[0m
Defcon: [31m2 FAST PACE[39m
FAIL
exit status 1
FAIL github.com/google/goterm/term 0.067s

syscall error

D:\01work\internal_software\trunk\devLicense\wlic\client>go version
go version go1.17 windows/amd64

D:\01work\internal_software\trunk\devLicense\wlic\client>go build

github.com/google/goterm/term

C:\Users\yxhlc\go\pkg\mod\github.com\google\[email protected]\term\termios.go:202:32: not enough arguments in call to syscall.Syscall
C:\Users\yxhlc\go\pkg\mod\github.com\google\[email protected]\term\termios.go:202:33: undefined: syscall.SYS_IOCTL
C:\Users\yxhlc\go\pkg\mod\github.com\google\[email protected]\term\termios.go:213:32: not enough arguments in call to syscall.Syscall
C:\Users\yxhlc\go\pkg\mod\github.com\google\[email protected]\term\termios.go:213:33: undefined: syscall.SYS_IOCTL
C:\Users\yxhlc\go\pkg\mod\github.com\google\[email protected]\term\termios.go:288:32: not enough arguments in call to syscall.Syscall
C:\Users\yxhlc\go\pkg\mod\github.com\google\[email protected]\term\termios.go:288:33: undefined: syscall.SYS_IOCTL
C:\Users\yxhlc\go\pkg\mod\github.com\google\[email protected]\term\termios.go:310:32: not enough arguments in call to syscall.Syscall
C:\Users\yxhlc\go\pkg\mod\github.com\google\[email protected]\term\termios.go:310:33: undefined: syscall.SYS_IOCTL
C:\Users\yxhlc\go\pkg\mod\github.com\google\[email protected]\term\termios.go:319:32: not enough arguments in call to syscall.Syscall
C:\Users\yxhlc\go\pkg\mod\github.com\google\[email protected]\term\termios.go:319:33: undefined: syscall.SYS_IOCTL
C:\Users\yxhlc\go\pkg\mod\github.com\google\[email protected]\term\termios.go:319:32: too many errors

D:\01work\internal_software\trunk\devLicense\wlic\client>

pty_linux.go:15:27: error: reference to undefined identifier 'syscall.TIOCGPTN' (gollvm)

Hi.
I think I found a bug.

$ go build -i -v -x
WORK=/tmp/go-build100086455
github.com/pkg/term/termios
mkdir -p $WORK/b014/
cd $WORK
/home/oceanfish81/gollvm_dist/bin/llvm-goc -fgo-importcfg=/dev/null -c -x c - -o /dev/null || true
cd /home/oceanfis81/go/pkg/mod/github.com/pkg/[email protected]/termios
/home/oceanfish81/gollvm_dist/bin/llvm-goc -c -O2 -g -m64 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -fgo-pkgpath=github.com/pkg/term/termios -o $WORK/b014/go.o -I $WORK/b014/importcfgroot ./doc.go ./ioctl.go ./pty.go ./pty_linux.go ./termios.go ./termios_const.go ./termios_linux.go

github.com/pkg/term/termios

../../../go/pkg/mod/github.com/pkg/[email protected]/termios/pty_linux.go:15:27: error: reference to undefined identifier 'syscall.TIOCGPTN'
../../../go/pkg/mod/github.com/pkg/[email protected]/termios/pty_linux.go:24:27: error: reference to undefined identifier 'syscall.TIOCGPTN'
../../../go/pkg/mod/github.com/pkg/[email protected]/termios/pty_linux.go:29:27: error: reference to undefined identifier 'syscall.TIOCSPTLCK'

Here is my environment:

$ go env && go version
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/oceanfis81/.cache/go-build"
GOENV="/home/oceanfis81/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/oceanfis81/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/oceanfis81/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/oceanfish81/gollvm_dist"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/oceanfish81/gollvm_dist/tools"
GCCGO="/home/oceanfish81/gollvm_dist/bin/llvm-goc"
AR="ar"
CC="/usr/bin/clang"
CXX="/usr/bin/clang++"
CGO_ENABLED="1"
GOMOD="/home/oceanfis81/go_projects/c4go/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build402447636=/tmp/go-build -gno-record-gcc-switches -funwind-tables"
go version go1.15.2 gollvm LLVM 12.0.0git linux/amd64

I am using gollvm - my "release" build could be found here

CC @thanm @cherrymui

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.