Elsa
Elsa

Reputation: 724

Termbox library can not be initialized at termbox-go

I'm creating an application using termbox-go. This library works fine at windows DOS (windows10). But at Bash on Ubuntu on Windows, it was found that when termbox.Init() is run, an error of invalid argument occurs. I thought that as a reason, tty of the terminal may be not raw mode. But I don't know the reason and method to avoid this problem.

My questions are below.

The version of Bash on Ubuntu on Windows is Ubuntu 16.04.3 LTS. The version of Go is 1.8.3. When runtime.GOOS is used, windows DOS and Bash on Ubuntu on Windows show windows and linux, respectively.

Script

package main

import (
    "log"
    "os"

    "github.com/nsf/termbox-go"
)

func main() {
    err := termbox.Init()
    if err != nil {
        log.Println(err.Error())
        os.Exit(1)
    }
}

Result

invalid argument

Error position

This error position was the below script at api.go.

_, err = fcntl(in, syscall.F_SETFL, syscall.O_ASYNC|syscall.O_NONBLOCK)

fcntl() is in termbox.go.

func fcntl(fd int, cmd int, arg int) (val int, err error) {
    r, _, e := syscall.Syscall(syscall.SYS_FCNTL, uintptr(fd), uintptr(cmd),
        uintptr(arg))
    val = int(r)
    if e != 0 {
        err = e
    }
    return
}

I don't know whether this position will be a solution.

Thank you so much for your time and advices. And I'm sorry for my immature question.

Upvotes: 3

Views: 555

Answers (0)

Related Questions