Re: [go-nuts] Having difficulty converting []byte to float

2018-05-18 Thread john . macrae . fox
After talking with a coworker it seems that "grep" returns a \n after its output. That was the bugger keeping my initial efforts from working. Grep was meant for "human consumption". I will need to look into buffio and scanner as Tamas suggested. On Friday, May 18, 2018 at 11:06:46 AM

Re: [go-nuts] Having difficulty converting []byte to float

2018-05-18 Thread john . macrae . fox
After talking with a coworker it seems that "grep" returns a \n after its output. That was the bugger keeping my initial efforts from working. On Friday, May 18, 2018 at 11:06:46 AM UTC-4, John Fox wrote: > > Drilling down farther for the heck of it > > os/exec/exec.go > func (c *Cmd) Output()

Re: [go-nuts] Having difficulty converting []byte to float

2018-05-18 Thread john . macrae . fox
Drilling down farther for the heck of it os/exec/exec.go func (c *Cmd) Output() ([]byte, error) { if c.Stdout != nil { return nil, errors.New("exec: Stdout already set") } var stdout bytes.Buffer c.Stdout = captureErr := c.Stderr == nil if captureErr { c.Stderr = {N: 32 << 10} }

Re: [go-nuts] Having difficulty converting []byte to float

2018-05-18 Thread john . macrae . fox
Thank you both for the quick responses. I looked in to https://github.com/lovoo/ipmi_exporter yesterday and saw the TrimSpace used as well, but I am still not sure what is adding the '\n' to the commands's Output(). Tamas, I will have to look into thebuff IO, even if I am not using this for

Re: [go-nuts] Having difficulty converting []byte to float

2018-05-17 Thread Jesse McNelis
On Fri, May 18, 2018 at 12:26 PM, wrote: > Hello all. I am creating a custom exporter for FreeNAS > https://github.com/Maelos/freenas_exporter and am stuck on the conversion of > the string of bytes provided by the commands output to a float. Here is my > code, what

[go-nuts] Having difficulty converting []byte to float

2018-05-17 Thread Tamás Gulácsi
The input is string, so use strconv.ParseFloat, or ParseInt (will there be non-integer number of cpus?) Just trim the LF with strings.TrimSpace. For production use, leave out the grep and bash, read the output lines directly with bufio.Scanner. -- You received this message because you are

[go-nuts] Having difficulty converting []byte to float

2018-05-17 Thread john . macrae . fox
Hello all. I am creating a custom exporter for FreeNAS https://github.com/Maelos/freenas_exporter and am stuck on the conversion of the string of bytes provided by the commands output to a float. Here is my code, what I have tried, and my results: What I have tried and results (commented so