👊
Go tutorial for Pythoner
  • Introduction
  • Install and Run Go
  • The structure of Go
    • First time you meet him
    • Functions
    • Return multiple results
    • Logic Control
    • Break loop and enumerate
    • List (Array or Slice)
    • Dict (Map)
    • Struct
    • Class (Methods)
    • Packages
  • Features of Go
  • Go modules
  • Web Server
    • Serving static files
    • A simple webserver
  • Go for Android
  • Where to go next
Powered by GitBook
On this page

Was this helpful?

  1. The structure of Go

Struct

Golang's struct is just like C++'s struct.

package main

import "fmt"

type box struct {
    length int16
    width int16
    hight int16
}

func main(){
    a_box := box{length: 3, width: 2, hight: 1}
    another_box := box{3, 2, 1} //if you got varible well_named, this way just fine

    fmt.Println(a_box.length)
    fmt.Println(another_box.width)
}
PreviousDict (Map)NextClass (Methods)

Last updated 4 years ago

Was this helpful?