google / goexpect

Expect for Go
BSD 3-Clause "New" or "Revised" License
759 stars 134 forks source link

Support for windows/amd64 ? #13

Open slass100 opened 6 years ago

slass100 commented 6 years ago

C:\Users\u1\go>go version go version go1.10.3 windows/amd64

C:\Users\u1\go>go get -v github.com/google/goexpect github.com/google/goterm/term # github.com/google/goterm/term src\github.com\google\goterm\term\termios.go:202:32: not enough arguments in call to syscall.Syscall src\github.com\google\goterm\term\termios.go:202:33: undefined: syscall.SYS_IOCTL src\github.com\google\goterm\term\termios.go:213:32: not enough arguments in call to syscall.Syscall src\github.com\google\goterm\term\termios.go:213:33: undefined: syscall.SYS_IOCTL src\github.com\google\goterm\term\termios.go:288:32: not enough arguments in call to syscall.Syscall src\github.com\google\goterm\term\termios.go:288:33: undefined: syscall.SYS_IOCTL src\github.com\google\goterm\term\termios.go:310:32: not enough arguments in call to syscall.Syscall src\github.com\google\goterm\term\termios.go:310:33: undefined: syscall.SYS_IOCTL src\github.com\google\goterm\term\termios.go:319:32: not enough arguments in call to syscall.Syscall src\github.com\google\goterm\term\termios.go:319:33: undefined: syscall.SYS_IOCTL src\github.com\google\goterm\term\termios.go:319:32: too many errors

arowden commented 6 years ago

Unfortunately goterm\term doesn't support windows or mac. I had this issue as well. Not sure why they coupled it so tightly to this project knowing that...

skalle commented 6 years ago

As you already figured out this is due to the term package being Linux only, mainly due to the PTY functions, this is needed when spawning local commands with the Expect package..

For spawners like SSH/Telnet/Fake/Generic this is not needed and it'd be fully possible to detect !Linux environments and skip the PTY parts when building as would adding PTY support for BSD/MacOS/Windows ..

I'd be more than happy to take a PRs to fix this but personally I don't have the time , or any boxes running !Linux for that matter , to make expect run on !Linux environments.

skalle commented 6 years ago

I've devised a bit of a plan here ... Plan is to use the Go build system to skip building the OpenPTY parts when building on !Linux platforms .. This should enable using goexpect everywhere except for the local process part..

skalle commented 6 years ago

Just an update, will be a bit longer before goexpect will build on a windows machine.

https://github.com/google/goterm/tree/buildExperiment - Began to split the builds up with that one ... Will need to change some stuff in Expect too before it'll build.

yingshaoxo commented 5 years ago

C:\Users\u1\go>go version go version go1.10.3 windows/amd64

C:\Users\u1\go>go get -v github.com/google/goexpect github.com/google/goterm/term

github.com/google/goterm/term

src\github.com\google\goterm\term\termios.go:202:32: not enough arguments in call to syscall.Syscall src\github.com\google\goterm\term\termios.go:202:33: undefined: syscall.SYS_IOCTL src\github.com\google\goterm\term\termios.go:213:32: not enough arguments in call to syscall.Syscall src\github.com\google\goterm\term\termios.go:213:33: undefined: syscall.SYS_IOCTL src\github.com\google\goterm\term\termios.go:288:32: not enough arguments in call to syscall.Syscall src\github.com\google\goterm\term\termios.go:288:33: undefined: syscall.SYS_IOCTL src\github.com\google\goterm\term\termios.go:310:32: not enough arguments in call to syscall.Syscall src\github.com\google\goterm\term\termios.go:310:33: undefined: syscall.SYS_IOCTL src\github.com\google\goterm\term\termios.go:319:32: not enough arguments in call to syscall.Syscall src\github.com\google\goterm\term\termios.go:319:33: undefined: syscall.SYS_IOCTL src\github.com\google\goterm\term\termios.go:319:32: too many errors

Same problem here.

yingshaoxo commented 5 years ago

I did a test:

Found that if I import "github.com/google/goexpect", the error will cause.


My compile command is:

export CGO_ENABLED=0

mkdir bin
rm bin/* -fr
cd bin

go get github.com/mitchellh/gox
gox -output="{{.OS}}_{{.Arch}}" -os="windows" -osarch="linux/amd64" -osarch="linux/arm" ../src
cd ..

It supposes to work well when I use the following code:

import (
    "github.com/google/goexpect"
    "runtime"
)

func windows_processing() {
}

func linux_processing() {
}

func macos_processing() {
}

func Doit() {
    if runtime.GOOS == "windows" {
        windows_processing()
    } else if runtime.GOOS == "linux" {
        linux_processing()
    } else if runtime.GOOS == "darwin" {
        macos_processing()
    }
}

runtime.GOOS will also work at compiling time.

You should add that check when you init this package. @skalle

yingshaoxo commented 5 years ago

Sorry for disturbing you guys.

runtime.GOOS will not work at the time of compiling.

Now I think Golang's cross-compiling system is quite Useless.

It works only if you use a non-native library.

https://stackoverflow.com/questions/43215655/building-multiple-binaries-using-different-packages-and-build-tags

niltooth commented 4 years ago

Any progress made on this?

skalle commented 4 years ago

Hey dev-mull and others following this.

Not much progress, all due to lack of cycles. I did have a BSD version going but never managed to get all the needed tests and such in.

If anywone would like to tackle this it'd be great, I'd be more than happy to get someone up to speed.

QGB commented 2 years ago

CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -trimpath -ldflags "-s -w -buildid=" undefined: syscall.SYS_IOCTL

undefined: syscall.TIOCSWINSZ