admin

Author


Go Language example

Hello Program:
package main
import fmt “fmt”
func main()
{
fmt.Printf(”Hello, world; or Καλημέρα κόσμε; or こんにちは 世界\n”);
}
package – package statement imports all the packages for using their facilities.
import fmt  “fmt” -  imports the package fmt for implementing formatted I/O.
func  – Functions are defined by using the keyword func .
main – main is the starting point of the program.
Frm.Printf() – [...]

Go Language Data Types

Numeric types
Numeric types are built in, will be familiar:

int

uint

float

int8

uint8 = byte

int16

uint16

int32

uint32

float32

int64

uint64

float64

Also uintptr, an integer big enough to store a pointer.
These are all distinct types; int is not int32 even on a 32-bit machine.
No implicit conversions.

Bool

The usual boolean type, bool, with values true and false (predefined constants).
The if statement etc. use boolean expressions.
Pointers and integers are [...]

Go Language Syntax Overview

Syntax overview
Basically C-like with reversed types and declarations, plus keywords to introduce each type of declaration.
Example:
var a int
var b, c *int // note difference from C
var d []int
type S struct { a, b int }

Basic control structures are familiar:
if a == b { return true } else { return false }
for i = 0; i [...]

Go Language Basics

Google has introduced the New open sourced programming language “Go”.
Go is a

New
Experimental
Concurrent
Garbage-collected
Systems Language

Lexical structure

Source is UTF-8. White space: blank, tab, newline.
Identifiers are alphanumeric (plus ‘_’) with “alpha” and “numeric” defined by Unicode.

Comments:
/* This is a comment; no nesting */
// So is this.
Literals
C-like but numbers require no signedness or size markings
Example:
23
0×0FF
1.234e7
C-like strings, but Unicode/UTF-8. Also \xNN [...]

Page 2 of 2«12