DrSchool Learn coding, fast.
EN AR BN CS DE EL Search

Go: Syntax

Go syntax starter + common patterns.

Read time: 1 min Words: 27
My Progress

Go — Syntax

Hello World

package main
import "fmt"
func main(){
  fmt.Println("Hello, World!")
}

Common patterns

Note: some languages differ. This page is a starter cheat sheet you can expand.

Comments

// line comment
/* block comment */

Variables (example)

// var / let / const / or language-specific syntax

Conditionals

// if / else

Loops

// for / while

Functions

// define a function