commit 02a0b207465e9d97683ffaf7f7231825ebd7c126 Author: Mark McGranaghan Date: Sun Sep 16 10:57:18 2012 -0700 init diff --git a/01-hello.go b/01-hello.go new file mode 100644 index 0000000..91e7378 --- /dev/null +++ b/01-hello.go @@ -0,0 +1,7 @@ +package main + +import "fmt" + +func main() { + fmt.Println("Hello World") +} diff --git a/02-numbers.go b/02-numbers.go new file mode 100644 index 0000000..e017c5f --- /dev/null +++ b/02-numbers.go @@ -0,0 +1,7 @@ +package main + +import "fmt" + +func main() { + fmt.Println("1 + 1 =", 1 + 1) +} diff --git a/03-strings.go b/03-strings.go new file mode 100644 index 0000000..6f2218c --- /dev/null +++ b/03-strings.go @@ -0,0 +1,9 @@ +package main + +import "fmt" + +func main() { + fmt.Println(len("Hello World")) + fmt.Println("Hello World"[1]) + fmt.Println("Hello " + "World") +} diff --git a/04-booleans.go b/04-booleans.go new file mode 100644 index 0000000..b339bea --- /dev/null +++ b/04-booleans.go @@ -0,0 +1,11 @@ +package main + +import "fmt" + +func main() { + fmt.Println(true && true) + fmt.Println(true && false) + fmt.Println(true || true) + fmt.Println(true || false) + fmt.Println(!true) +} diff --git a/05-variable.go b/05-variable.go new file mode 100644 index 0000000..3988946 --- /dev/null +++ b/05-variable.go @@ -0,0 +1,8 @@ +package main + +import "fmt" + +func main() { + var x string = "Hello World" + fmt.Println(x) +} diff --git a/06-mutation.go b/06-mutation.go new file mode 100644 index 0000000..7283a51 --- /dev/null +++ b/06-mutation.go @@ -0,0 +1,11 @@ +package main + +import "fmt" + +func main() { + var x string + x = "first" + fmt.Println(x) + x = "second" + fmt.Println(x) +} diff --git a/07-literal.go b/07-literal.go new file mode 100644 index 0000000..21e7a50 --- /dev/null +++ b/07-literal.go @@ -0,0 +1,8 @@ +package main + +import "fmt" + +func main() { + x := "Hello World" + fmt.Println(x) +} diff --git a/08-constant.go b/08-constant.go new file mode 100644 index 0000000..84f09ad --- /dev/null +++ b/08-constant.go @@ -0,0 +1,9 @@ +package main + +import "fmt" + +const x string = "Hello World" + +func main() { + fmt.Println(x) +} diff --git a/09-input.go b/09-input.go new file mode 100644 index 0000000..730c298 --- /dev/null +++ b/09-input.go @@ -0,0 +1,11 @@ +package main + +import "fmt" + +func main() { + fmt.Print("Enter a number: ") + var input float64 + fmt.Scanf("%f", &input) + output := input * 2 + fmt.Println(input, "* 2 =", output) +}