Skip to content

Instantly share code, notes, and snippets.

@makotom
Created May 2, 2020 11:02
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 makotom/8de8ba91cdea3c6ec71af39c6dff67bb to your computer and use it in GitHub Desktop.
Save makotom/8de8ba91cdea3c6ec71af39c6dff67bb to your computer and use it in GitHub Desktop.
Convert config.yml into JSON
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
yaml "github.com/notnoopci/yaml"
)
func main () {
var result map[string]interface{}
config, _ := ioutil.ReadFile("config.yml")
yaml.Unmarshal(config, &result)
jsonStr, _ := json.Marshal(result)
fmt.Printf("%v\n", string(jsonStr))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment