👊
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

First time you meet him

package main

import (
    "fmt"
)

func main() {
    var x string
    x = "Hello"

    y := "world"

    var sentence string = x + ", " + y + "!"

    fmt.Println(sentence)
    fmt.Printf("%s, %s!", y, x)
}

As you can see, Go is a kind of combination of Python, C++, JavaScript.

  1. package, have no idea yet.

  2. func main() {} is like C or C++ codes structure, which without ; to determine if a statement was finished.

  3. var x string is like the way of declaring a variable in JavaScript.

  4. y := "world" is like Python, in there, the compiler will automatically figure out the variable type without you to declare. fmt.Println() is like Python's print(), and revealed the relationship of Class and Function.

PreviousThe structure of GoNextFunctions

Last updated 4 years ago

Was this helpful?