abiosoft / abiosoft/ishell

Wrong output from shell.Println when receiving from a goroutine

未关闭
#19 11 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看
in progress
主要语言
Go
星标
1.8k
派生
213
PR 合并指标
30 天内没有已合并 PR

描述

I am trying to print some output from a channel to the shell. When receiving from a goroutine it prints without a newline and does not give the prompt back. Example:
```go
package main

import (
"time"
"github.com/abiosoft/ishell"
)

func feed(c chan string) {
for i := 0; i<3; i++ {
c <- "Feedback"
time.Sleep(time.Second)
}
}

func main(){
shell := ishell.New()
c := make(chan string)

// listen
go func() {
for msg := range(c) {
shell.Println(msg)
}
}()

// this does output correctly
//feed(c)
// this does not
go feed(c)

shell.Start()
}
```
`go feed(c)` outputs:
```bash
>>> Feedback
Feedback
Feedback
```
To get the prompt back you have to type a letter

`feed(c)` outputs correctly:
```bash
Feedback
Feedback
Feedback
>>>
```

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。