Original post

package main

import (


type instanceConfig struct {
        Name    string `yaml:"Name"`
        Address string `yaml:"Address"`
        Phone   int    `yaml:"Phone"`
        WFH     bool

        Internships string `yaml:"Internships"`

func (c *instanceConfig) Parse(data []byte) error {
        return yaml.Unmarshal(data, c)

func main() {
        data, err := ioutil.ReadFile("file.yml")
        if err != nil {
        var config instanceConfig
        if err := config.Parse(data); err != nil {
        fmt.Printf("%+vn", config)

I am trying to parse yaml in GO. Two problems:

  1. why is it necessary to define each mapping in yaml like yaml:"Name" …it cant just map the first item to first key?

  2. how can I output the Internships as a list within the yaml? Adding ‘Internships list yaml:"Internships"’ did not work at all.

    Name: “Arka”
    Address: “India”
    Phone: 100
    WorkFromHome: true
    Mail: “abc@hotmail.com

    – JournalDev
    – MNO
    – ABC
    – XYZ
    MSc: 7.6
    BSc: 8.1
    XII: 9
    Udemy: 15
    Coursera: 3
    References: “Mr. QWERTY, XYZ”