Setting up structs

Published: Sunday, Dec 15, 2013 Last modified: Saturday, Jul 24, 2021

Examples of how to populate a struct.

package main

import "fmt"

type event struct {
	Name string
	Date string
}

type events []event

func main() {
	e1 := event{}
	e1.Date = "Today"
	e1.Name = "Somethiing"
	e2 := event{Date: "Tomorrow", Name: "Dentist"}

	s := events{e1, e2}

	fmt.Printf("%+v\n", s)

}