Removed superfluous brackets from main()

This commit is contained in:
Samuel Hawksby-Robinson 2020-06-11 17:05:12 +01:00
parent 48843e69df
commit 02693db047
No known key found for this signature in database
GPG Key ID: 64CF99D4A64A1205
1 changed files with 18 additions and 22 deletions

View File

@ -124,31 +124,27 @@ func processTranslation(v string) string {
func main() {
var r io.Reader
{
if len(os.Args) == 2 {
f, err := os.Open(os.Args[1])
if err != nil {
fmt.Fprintf(os.Stderr, "error reading file: %q", err)
os.Exit(1)
}
r = f
} else {
r = bufio.NewReader(os.Stdin)
if len(os.Args) == 2 {
f, err := os.Open(os.Args[1])
if err != nil {
fmt.Fprintf(os.Stderr, "error reading file: %q", err)
os.Exit(1)
}
r = f
} else {
r = bufio.NewReader(os.Stdin)
}
var rs Resources
{
if err := json.NewDecoder(r).Decode(&rs); err != nil {
fmt.Fprintf(os.Stderr, "error parsing json: %q", err)
os.Exit(1)
}
b, err := xml.MarshalIndent(rs, "", "\t")
if err != nil {
fmt.Fprintf(os.Stderr, "error serializing xml: %q", err)
os.Exit(1)
}
fmt.Println(string(b))
if err := json.NewDecoder(r).Decode(&rs); err != nil {
fmt.Fprintf(os.Stderr, "error parsing json: %q", err)
os.Exit(1)
}
b, err := xml.MarshalIndent(rs, "", "\t")
if err != nil {
fmt.Fprintf(os.Stderr, "error serializing xml: %q", err)
os.Exit(1)
}
fmt.Println(string(b))
}