Select language
Română
English
Français
Deutsch
Italiano
Español
Home
Languages ▾
CPP
C
CS
GO
JAVA
Python
Html
JS
CSS
PHP
Hard Lessons ▾
Hard Lesson 1
Hard Lesson 2
Hard Lesson 3
Hard Lesson 4
Hard Lesson 5
Hard Lesson 6
Hard Lesson 7
Hard Lesson 8
Hard Lesson 9
Hard Lesson 10
Hard Lesson 11
Hard Lesson 12
Compiler
Account
GO(Golang)
Example
package main import "fmt" func main() { var n int fmt.Print("Input: ") fmt.Scan(&n) fmt.Println("You entered:", n) } OUTPUT: Input: 5 You entered: 5
Variables
- int - EX: 100 - Size: depends on system (commonly 4 or 8 bytes) - float32 - EX: 5.67 - Size: 4 bytes - float64 - EX: 5.678 - Size: 8 bytes - byte - EX: 'A' - Alias for uint8 - Size: 1 byte - rune - EX: '字' - Unicode code point - Size: 4 bytes - string - EX: "Hello" - Size: depends on length - bool - EX: true / false - Size: 1 byte - uint, int8, int16, int32, int64 - various sizes - var name type = value OR name := value
Input
import "fmt" var number int fmt.Print("Enter number: ") fmt.Scan(&number) fmt.Println("Number:", number) var character rune fmt.Print("Enter character: ") fmt.Scanf("%c", &character) fmt.Println("Character:", string(character))
Output
fmt.Print("text") // No newline fmt.Println("text") // With newline fmt.Printf("Value: %d\n", x) // Formatted fmt.Println('A') // Runes as int fmt.Println(string(65)) // Outputs: A fmt.Println("Line1\nLine2") // New lines fmt.Println("Tab\tHere") // Tab
Comments
// This is a single-line comment /* This is a multi-line comment. It can span multiple lines. */
Functions
func Add(a int, b int) int { return a + b } // Call: result := Add(5, 3) fmt.Println(result) func Greet(name string) { fmt.Println("Hello", name) } // void = no return value in Go // Function names start with lowercase (private) or uppercase (exported)