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

如何在GOlang程序中检测linux发行?

I want to write linux distribution independant Golang code. I need detect which linux distribution and need to run distribution specific commands within program. Like dpkg in case of Ubuntu and rpm -q in case of RHEL.

You can use exec.Cmd to run lsb_release -a or uname -a and parse the output to find out the distribution.

Reference

近期文章

  • NameError:名称“ go”未在sublime text 3控制台中定义
  • Golang中多个int片段的序列比对
  • 管道执行流程
  • 选择一个元素数量有限的数组的文档
  • 在Go中返回JSON
  • 在单独的方法中使用golang的defer
  • 使用条带库在Go中解组数据
  • App Engine go context.Context没有名称空间
  • 安装依赖项时,如何解决“ go get./…”问题?
  • 具有golang属性的xml文档
  • 如何在Go中设置空授权标头?
  • 如何在日志中识别线程或类似线程?
  • 相当于Python的NotImplementedException的Golang
  • 如何遍历结构的字段以进行查询过滤
  • 我可以在boltdb的嵌套存储桶下创建嵌套存储桶吗?
  • 在Go中解析YAML:列表中的映射
  • Golang:sqlx StructScan将db列映射到struct
  • 怎么把Go struct转换成C struct?
  • 通过gzip将命令输出到Reader
  • 转到模板:一起使用嵌套结构的字段和{{range}}标签

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

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

友情链接:代码精华