Skip to content

Instantly share code, notes, and snippets.

@xnuk
Created December 25, 2018 00:49
Show Gist options
  • Save xnuk/2521d437fde1ef8cfeac46bde8ed1bfd to your computer and use it in GitHub Desktop.
Save xnuk/2521d437fde1ef8cfeac46bde8ed1bfd to your computer and use it in GitHub Desktop.
package main
import (
"os"
"fmt"
"strings"
"io/ioutil"
yaml "gopkg.in/yaml.v2"
)
func main() {
args := os.Args[1:]
if len(args) < 1 {
paths := strings.Split(os.Args[0], "/")
filename := paths[len(paths)-1]
fmt.Printf("Usage: %s [PATH]\n", filename)
os.Exit(255)
}
path := args[len(args)-1]
file_raw, err := ioutil.ReadFile(path)
if err != nil { panic(err) }
var t yaml.MapSlice
err = yaml.Unmarshal(file_raw, &t)
if err != nil { panic(err) }
fmt.Printf("%v", t)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment