func writeBytesBufferMessage(out *bytes.Buffer, cmdRunner *utils.DeployCmdRunner, ws *websocket.Conn) { for { loop: if out.Len() == 0 { if cmdRunner.Exited() { break } else { time.Sleep(time.Second) goto loop } } again: line, _ := out.ReadBytes('\n') //按行读取 if line != nil { writeBytesMessage(ws, line) goto again } else { goto loop } } }
func ReadAndWriteBytes(out *bytes.Buffer, cmdRunner *utils.DeployCmdRunner) { for { loop: if out.Len() == 0 { if cmdRunner.Exited() { break } else { time.Sleep(time.Second) goto loop } } again: line, _ := out.ReadBytes('\n') if line != nil { fmt.Println(string(line)) goto again } else { goto loop } } }