πΈοΈMiscellaneous
This page documents the part of the language that were not "big" enough to warrant an entire page.
Line Comments
Syntax
// Comment hereWorking Example
package main
import "fmt" as fmt
fun main(): Unit {
fmt.println("Hello world!") // This is a comment
}package main
import fmt "fmt"
func main() {
fmt.Println("Hello world!")
}
Hello world!Array Literal
You can use an array literal to construct an array.
Syntax
-OR-
Working Example
Slice Literal
You can use a slice literal to construct a slice.
Syntax
Working Example
Map Literal
Map literals can be used to construct maps
Syntax
Working Example
Indexing
The indexing operator can be used on arrays, slices, strings, maps, and pointers to arrays
Syntax
Working Example
Slicing
Slicing can only be done on strings, slices, and arrays
Syntax:
Working Example
Tuples
Syntax
Working Example
Type Assertion
Syntax
Working Example
Type Conversion
Syntax
Working Example
Goroutines
Syntax
Working Example
Defer
Syntax
Working Example
Pointers & Dereferencing
Pointer Syntax
Dereferencing Syntax
Working Example
Sending and Receiving with Channels
Sending Syntax
Receiving Syntax
Working Example
Negated Expression
Syntax
Working Example
Last updated