我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

有什么通用的方法来检查os.Stdin或从空设备重定向的输入?

I would like to check input is redirected to null device or not in go language.I got one way for unix but I don't how to deal with windows or make it generic.This is what I did for unix

fd := os.Stdin.Fd()
fmt.Print(fmt.Sprint("/proc/self/fd/", fd))
fileName, err1 := os.Readlink(fmt.Sprint("/proc/self/fd/", fd))

if err1 != nil {
    fmt.Print(err1)
}
fmt.Println("fileName:", fileName)

近期文章

  • Dockerfile连接到ODBC(例如HPE Vertica)设置
  • “ go install”,“ govendor install + local”和“ govendor install + vendor,^ program”有什么区别?
  • 如何在golang上的现有ssh连接上创建sftp客户端
  • 使用io.Multiwriter创建跨包/子包的日志
  • 竞赛检测器运行时错误
  • Golang切片问题
  • 使用MySQL的表单插入既是主键又是默认值的字段
  • Golang编码/ JSON马歇尔添加空
  • Golang中功能范围的模拟
  • golang http(或gocraft)速率限制
  • 如何在Kubernetes中添加新软件包
  • 导入特定包装
  • 转到错误拨号TCP:协议不可用
  • gocron创建任务的多个实例
  • C++多线程调用JNI的问题
  • 使用mapstructure处理界面数据
  • golang / glog在我的服务器上创建了数百个小文件
  • 如何与Go并发理解和练习?
  • goroutines问题
  • 调试时如何在golang中检查数组元素

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华