33 lines
543 B
Go
33 lines
543 B
Go
/* Common structures and methods used across all coreutils */
|
|
|
|
package jsh
|
|
|
|
import (
|
|
"encoding/json"
|
|
)
|
|
|
|
type JshOutput struct {
|
|
StdOut interface{}
|
|
StdErr interface{}
|
|
}
|
|
|
|
// Size prefixes as integers, using binary representation
|
|
type Unit int
|
|
const (
|
|
B Unit = 2 ^ 0
|
|
KB Unit = 2 ^ 10
|
|
MB Unit = 2 ^ 20
|
|
GB Unit = 2 ^ 30
|
|
TB Unit = 2 ^ 40
|
|
)
|
|
|
|
// Converts a Jshoutput into a JSON string
|
|
func (j JshOutput) ToJson() *string {
|
|
jsonOut, err := json.Marshal(j)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
jsonString := string(jsonOut)
|
|
return &jsonString
|
|
}
|