Created
November 20, 2017 14:29
-
-
Save suzuki-shunsuke/0dd0a5ef1515c99962a12140dc88d5bd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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