duang5049 2017-08-28 04:40
浏览 80

Termbox库无法在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.

  • Why does this error occur?
  • What is the solution of this problem?

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.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 孟德尔随机化结果不一致
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀
    • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
    • ¥15 关于#hadoop#的问题
    • ¥15 (标签-Python|关键词-socket)
    • ¥15 keil里为什么main.c定义的函数在it.c调用不了
    • ¥50 切换TabTip键盘的输入法
    • ¥15 可否在不同线程中调用封装数据库操作的类