forked from Archives/tson
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
422 B
Go
35 lines
422 B
Go
5 years ago
|
package main
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"fmt"
|
||
|
"io/ioutil"
|
||
|
"log"
|
||
|
"os"
|
||
|
|
||
|
"golang.org/x/crypto/ssh/terminal"
|
||
|
)
|
||
|
|
||
|
func run() int {
|
||
|
if !terminal.IsTerminal(0) {
|
||
|
b, err := ioutil.ReadAll(os.Stdin)
|
||
|
if err != nil {
|
||
|
log.Println(err)
|
||
|
return 1
|
||
|
}
|
||
|
var t interface{}
|
||
|
if err := json.Unmarshal(b, &t); err != nil {
|
||
|
log.Println(err)
|
||
|
return 1
|
||
|
}
|
||
|
|
||
|
fmt.Println(t)
|
||
|
}
|
||
|
|
||
|
return 0
|
||
|
}
|
||
|
|
||
|
func main() {
|
||
|
os.Exit(run())
|
||
|
}
|