What are Go Structs? (golang)

Creating a Struct

type Superhero struct {
firstName string
lastName string
planet string
age int
powers []string
wonderWoman := Superhero{
firstName: "Diana",
lastName: "Prince",
planet: "Earth-Two",
age: 800,
powers: []string{
"Super Strength",
"Astral Projection",
fmt.Println(wonderWoman.firstName) //Dianafmt.Println(WonderWoman.powers[1]) //Telepathy

Anonymous Struct

myDog := struct {
name string
breed string
age int
}{name: "Bro", breed: "Chihuahua", age: 10}





Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Buying.com Weekly Bulletin 1/13/22

Raspberry Pi4 as a Desktop/Gaming PC.

Day 11 with GameDevHQ

GraphQL Attribute-Based Access Control in Arboric

Chapter 7 Attorney

chapter 7 attorney

Let’s create a REST API with Django Rest Framework !!

Deploy NKN Full Node from AWS Marketplace

Add GitHub ssh-agent and ssh key on startup (Windows)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Sean Dever

Sean Dever

More from Medium

In-depth analysis of Golang memory escape

Golang — basic unit testing and benchmarking

Pointer in Golang

How to Check nil Interface in Golang?