goexpect icon indicating copy to clipboard operation
goexpect copied to clipboard

Support for windows/amd64 ?

Open slass100 opened this issue 6 years ago • 10 comments

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

slass100 avatar Jun 08 '18 19:06 slass100

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...

arowden avatar Jun 19 '18 18:06 arowden

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 avatar Jul 04 '18 07:07 skalle

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 avatar Jul 15 '18 23:07 skalle

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.

skalle avatar Jul 19 '18 13:07 skalle

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 avatar Nov 05 '19 03:11 yingshaoxo

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 avatar Nov 05 '19 04:11 yingshaoxo

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

yingshaoxo avatar Nov 05 '19 16:11 yingshaoxo

Any progress made on this?

niltooth avatar Mar 19 '20 13:03 niltooth

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.

skalle avatar Mar 27 '20 02:03 skalle

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

undefined: syscall.TIOCSWINSZ

QGB avatar Jul 10 '22 04:07 QGB