package main
import "fmt"
/* This is a multiline
* comment
*/
func main() {
fmt.Println("Hello World!") // This is a comment
fmt.Println (`--------------
Thiaa is a multine string
------------------------`);
}Go is a compiled programming language, relatively recent.
Go source files have the .go extension. Of course.
We see how the language takes several elements from C/C++. The
comments and the grouping of instructions are identical. Instead of
include it uses import like Python (although
we haven’t seen this yet). We can ignore the package
instruction for now.
As we can observe, Go uses the same solution as Java, adding the
characters ln (of line, line in English) to the
Print function when we want to include a carriage return at
the end of our string.
DID YOU KNOW…
The Go language offers native support for concurrent programming. One of the most unique features in this aspect are the calls
goroutinesandchannels.Goroutinescan be seen as a kind of threads, whilechannelsare a mechanism for exchanging messages betweengoroutines.
In addition to all that, we can define multi-line strings using backticks.
We can execute our program directly using the command:
$ go run hello.go
Or generate an executable
$ go build hello.go
$ ./hello
Go was designed at Google by Robert Griesemer, Rob Pike, and Jen Thompson (a few heavyweights on the list) in 2007. The language was conceived to improve programming productivity in the era of networked machines, multi-core processors, and large codebases.
The language was publicly announced in 2009 and released in 2012.
You can install the development tools for the Go language using the following command in Debian-based distributions:
apt install golang
Summary
- Compiled language
- Extension:
go - Line terminator:
; - Groups instructions with: Depends on the command
- Multi-line comments: Using
/* ... */ - Single-line comments:
// - String delimiter:
"string"or`string` - You can print text with
fmt.Println(Adds carriage return) - Supports multi-line strings: Depends on the operation
- Does not Support
HERE-DOCS - Entry Point:
mainfunction