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 摘要。