Skip to content

Instantly share code, notes, and snippets.

@suzuki-shunsuke
Created November 20, 2017 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save suzuki-shunsuke/0dd0a5ef1515c99962a12140dc88d5bd to your computer and use it in GitHub Desktop.
Save suzuki-shunsuke/0dd0a5ef1515c99962a12140dc88d5bd to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"io/ioutil"
"os"
"github.com/ghodss/yaml"
)
func doMain(filePath string) ([]byte, error) {
buf, err := ioutil.ReadFile(filePath)
if err != nil {
return buf, err
}
return yaml.YAMLToJSON(buf)
}
func main() {
if len(os.Args) != 2 {
fmt.Fprintln(os.Stderr, "invalid arguments")
os.Exit(1)
}
buf, err := doMain(os.Args[1])
if err != nil {
fmt.Fprintf(os.Stderr, "err: %v\n", err)
os.Exit(1)
}
fmt.Println(string(buf))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment