FAQ
upto this i am able to write to get the program ,i only wanted to get the
video card info
package main
import (
  "fmt"
  "os/exec"
  "strings"
  "regexp"
)
func main(){
  var str string
  var s string
  out1,_ :=exec.Command("lspci").Output()
  str = string(out1[:])
  fmt.Println(str)
  str2:=strings.Split(str,"\n")
  r := regexp.MustCompile(`\S+\s([^:]+):\s*(.+?)(?:\(([^()]+)\))?`)
// r1 := regexp.MustCompile(`graphics|vga|video`)
  for _,j:=range str2 {

   in := []byte(j)
   b := r.Find(in)
   if b != nil {
   s = string(b)
   fmt.Println(s)
   }

  }

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Konstantin Khomoutov at Nov 23, 2015 at 2:22 pm

    On Mon, 23 Nov 2015 05:56:59 -0800 (PST) GKV wrote:

    upto this i am able to write to get the program ,i only wanted to get
    the video card info
    package main [...]
    out1,_ :=exec.Command("lspci").Output()
    str = string(out1[:])
    fmt.Println(str)
    str2:=strings.Split(str,"\n")
    r := regexp.MustCompile(`\S+\s([^:]+):\s*(.+?)(?:\(([^()]+)\))?`)
    [...]

    Please, next time make a shared entry on play.golang.org
    instead with a minimal runnable example.

    You see, given your question as stated, the set of folks able to answer
    is limited to those who has access to a Linux-based system with a video
    card on it, and they have to run `lspci` to actually see the output
    you're trying to parse. Don'y you think it's a fair bit too much to
    demand on your side? ;-)

    As to the question as stated -- wouldn't it be better to call
    `lspci -vvm` to produce a machine-readable format and parse it
    chunk-by-chunk (looking for the "Class" entry) in each of them?

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedNov 23, '15 at 1:57p
activeNov 23, '15 at 2:22p
posts2
users2
websitegolang.org

2 users in discussion

GKV: 1 post Konstantin Khomoutov: 1 post

People

Translate

site design / logo © 2022 Grokbase