Go fmt
This commit is contained in:
parent
50c84a2f7d
commit
64600ac668
2
cat.go
2
cat.go
@ -2,5 +2,5 @@ package jsh
|
||||
|
||||
type CatOutput struct {
|
||||
Output string
|
||||
Files []string
|
||||
Files []string
|
||||
}
|
||||
|
@ -3,26 +3,28 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"jsh"
|
||||
"io/ioutil"
|
||||
"jsh"
|
||||
)
|
||||
|
||||
func catFiles(queue chan *jsh.JshFrame) {
|
||||
// Get all of the non-flags. The rest were processed by the main function
|
||||
fileNames := flag.Args()
|
||||
for _,fileName := range fileNames {
|
||||
for _, fileName := range fileNames {
|
||||
file, err := ioutil.ReadFile(fileName)
|
||||
|
||||
var jshFrame jsh.JshFrame
|
||||
|
||||
// If there's an error, output an error frame to the queue and continue
|
||||
if err != nil {
|
||||
errText := make(map[string]string)
|
||||
errText[fileName] = fmt.Sprintf("%s",err.Error())
|
||||
errText[fileName] = fmt.Sprintf("%s", err.Error())
|
||||
jshFrame = jsh.JshFrame{"", errText}
|
||||
queue <- &jshFrame
|
||||
continue
|
||||
}
|
||||
|
||||
// Put the file contents into a frame and send them to the output
|
||||
output := jsh.CatOutput{}
|
||||
output.Files = []string{fileName}
|
||||
output.Output = string(file)
|
||||
@ -51,4 +53,3 @@ func main() {
|
||||
runJsonMode()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,8 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"jsh"
|
||||
"testing"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func testUnitError(expected jsh.Unit, t *testing.T) {
|
||||
@ -45,7 +45,7 @@ func TestConvertBadUnit(t *testing.T) {
|
||||
|
||||
func TestParseGoodLine(t *testing.T) {
|
||||
goodLine := "MemTotal: 16370344 kB"
|
||||
expectedStat := jsh.MemStat { 16370344, jsh.KB }
|
||||
expectedStat := jsh.MemStat{16370344, jsh.KB}
|
||||
expectedKey := "MemTotal"
|
||||
key, stat, err := ParseLine(goodLine)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user