This commit is contained in:
Mark McGranaghan 2012-09-20 19:17:39 -07:00
parent 0606feeea7
commit c179a25a6a
2 changed files with 12 additions and 4 deletions

View File

@ -7,8 +7,7 @@ import "fmt"
func main() {
fmt.Println("Hello world") // Strings - you already saw these.
fmt.Println("Hello World"[1])
fmt.Println("Hello " + "World")
fmt.Println("Hello " + "other")
fmt.Println("1+1 =", 1+1) // Integers and floats.
fmt.Println("7.0/3.0 =", 7.0/3.0)
@ -18,5 +17,13 @@ func main() {
fmt.Println(!true)
}
// This is just a sampling of Go's value types. We'll
// learn more about them as we go.
/*
$ go run 02-values.go
Hello world
Hello other
1+1 = 2
7.0/3.0 = 2.3333333333333335
false
true
false
*/

View File

@ -7,6 +7,7 @@ func p(o interface{}) {
}
func main() {
p("hello"[0])
p(strings.Contains("test", "es"))
p(strings.Count("test", "t"))
p(strings.HasPrefix("test", "te"))