An example of a struct in Go

This is an example Go program showing a struct.

package main

import (

type T struct {
        name string
        value int

func main() {
        var puppy T = "Pinky"
        puppy.value = 100;


The output of the example looks like this:

{Pinky 100}

Copyright © Ben Bullock 2009-2024. All rights reserved. For comments, questions, and corrections, please email Ben Bullock ( or use the discussion group at Google Groups. / Privacy / Disclaimer