golang – 使用io.Copy从bufio.Reader复制到STDOUT的怪异字符
我有一个应用程序,附加到一个docker容器得到它的输出使用docker库提供的containerAttach()函数。 该函数返回一个带有指向bufio.Reader的指针的HijackedResponse结构体。
我试图将文本从bufio.Readerstream到标准输出,并获取写入标准输出的string中的意外字符。
代码:
_, err := io.Copy(os.Stdout, hijackedResponse.Reader)
预期产出:
Refreshing Terraform state in-memory prior to plan... The refreshed state will be used to calculate this plan, but will not be persisted to local or remote state storage.
实际产出:
6Refreshing Terraform state in-memory prior to plan... =The refreshed state will be used to calculate this plan, but 9will not be persisted to local or remote state storage.
我不知道每一行的第一个字是从哪里来的。 任何帮助将非常感激。 如果需要的话,我可以提供更多的细节,我在我的代码中使用的docker容器和附加选项,虽然我假设他们罚款,因为我通过阅读器得到的输出。
我发现这个问题 – 我的containerConfig需要指定Tty: true
- 端口被阻止:无法在Ubuntu上安装Docker Universal Control Plane
- javax.naming.NameNotFoundException:名称未在此上下文中绑定。 无法find
- “使用的内存”度量标准:转到工具pprof与docker统计信息
- 用于testing使用Docker客户端API的方法的接口错误types错误
- 为什么CreateContainerOptions的卷需要一个map struct {}?
- 在docker的CPU使用率计算是什么:TotalUsage,SystemUsage,PercpuUsage和计算是什么意思?
- 消息:读取ECONNRESET,堆栈:错误:从Docker容器内的Go客户端调用HapiJs服务器时读取ECONNRESET
- 如何确定docker exec中的cmds何时完成
- 如何将Docker Web应用程序容器连接到Docker PostgreSQL容器?
- 如何让Vim不要求确认交互?
- AWS Elastic Beanstalk应用程序和静态资产部署隔离