more consistent case

This commit is contained in:
Mark McGranaghan 2012-10-17 17:22:24 -07:00
parent 5b906cd049
commit fdf2b6dbce
8 changed files with 18 additions and 19 deletions

View File

@ -6,7 +6,7 @@ package main
import "fmt" import "fmt"
// Use `const` to declare a constant value. // Use `const` to declare a constant value.
const s string = "Constant" const s string = "constant"
func main() { func main() {
fmt.Println(s) fmt.Println(s)

View File

@ -1,3 +1,2 @@
$ go run constant.go $ go run constant.go
Constant constant

View File

@ -1,9 +1,9 @@
// Our first program will print the classic "Hello world"` // Our first program will print the classic "hello world"`
// message. Here's the full source code. // message. Here's the full source code.
package main package main
import "fmt" import "fmt"
func main() { func main() {
fmt.Println("Hello world") fmt.Println("hello world")
} }

View File

@ -1,7 +1,7 @@
# To run the program, put the code in `hello-world.go` and # To run the program, put the code in `hello-world.go` and
# use `go run`. # use `go run`.
$ go run hello-world.go $ go run hello-world.go
Hello world hello world
# Sometimes we'll want to build our programs into # Sometimes we'll want to build our programs into
# binaries. We can do this using `go build`. # binaries. We can do this using `go build`.
@ -11,7 +11,7 @@ hello-world hello-world.go
# We can then execute the built binary directly. # We can then execute the built binary directly.
$ ./hello-world $ ./hello-world
Hello world hello world
# Now that we can run and build basic Go programs, let's # Now that we can run and build basic Go programs, let's
# learn more about the language. # learn more about the language.

View File

@ -10,7 +10,7 @@ func main() {
// Here's a basic `switch`. // Here's a basic `switch`.
i := 2 i := 2
fmt.Print("Write ", i, " as ") fmt.Print("write ", i, " as ")
switch i { switch i {
case 1: case 1:
fmt.Println("one") fmt.Println("one")
@ -25,9 +25,9 @@ func main() {
// `default` case in this example as well. // `default` case in this example as well.
switch time.Now().Weekday() { switch time.Now().Weekday() {
case time.Saturday, time.Sunday: case time.Saturday, time.Sunday:
fmt.Println("It's the weekend") fmt.Println("it's the weekend")
default: default:
fmt.Println("It's a weekday") fmt.Println("it's a weekday")
} }
// `switch` without an expression is an alternate way // `switch` without an expression is an alternate way
@ -36,9 +36,9 @@ func main() {
t := time.Now() t := time.Now()
switch { switch {
case t.Hour() < 12: case t.Hour() < 12:
fmt.Println("It's before noon") fmt.Println("it's before noon")
default: default:
fmt.Println("It's after noon") fmt.Println("it's after noon")
} }
} }

View File

@ -1,5 +1,5 @@
$ go run switch.go $ go run switch.go
Write 2 as two write 2 as two
It's the weekend it's the weekend
It's before noon it's before noon

View File

@ -9,7 +9,7 @@ import "fmt"
func main() { func main() {
// `var` declares 1 or more variables. // `var` declares 1 or more variables.
var a string = "Initial" var a string = "initial"
fmt.Println(a) fmt.Println(a)
// You can declare multiple variables at once. // You can declare multiple variables at once.
@ -29,6 +29,6 @@ func main() {
// The `:=` syntax is shorthand for declaring and // The `:=` syntax is shorthand for declaring and
// initializing a variable, e.g. for // initializing a variable, e.g. for
// `var f string = "Short"` in this case. // `var f string = "Short"` in this case.
f := "Short" f := "short"
fmt.Println(f) fmt.Println(f)
} }

View File

@ -1,6 +1,6 @@
$ go run variables.go $ go run variables.go
Initial initial
1 2 1 2
true true
0 0
Short short