add chapter 5 and refactor root path
This commit is contained in:
@@ -2,7 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"golang-book/head-first-go/chapter4/greeting"
|
||||
"headfirstgo/headfirstgo/chapter4/greeting"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
14
chapter4/hi/main.go~
Normal file
14
chapter4/hi/main.go~
Normal file
@@ -0,0 +1,14 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"headfirstgo/headfirstgo/chapter4/greeting"
|
||||
)
|
||||
|
||||
func main() {
|
||||
greeting.Hello()
|
||||
greeting.Hi()
|
||||
|
||||
slc := []string{"hello", "world"}
|
||||
fmt.Printf("%s %T %T", slc[0], slc, true)
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"golang-book/head-first-go/chapter4/keyboard"
|
||||
"headfirstgo/headfirstgo/chapter4/keyboard"
|
||||
"log"
|
||||
)
|
||||
|
||||
|
||||
23
chapter4/passfail/pass_fail.go~
Normal file
23
chapter4/passfail/pass_fail.go~
Normal file
@@ -0,0 +1,23 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"headfirstgo/headfirstgo/chapter4/keyboard"
|
||||
"log"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Print("Enter a grade: ")
|
||||
grade, err := keyboard.GetFloat()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
var status string
|
||||
if grade >= 60 {
|
||||
status = "passing"
|
||||
} else {
|
||||
status = "failing"
|
||||
}
|
||||
fmt.Println("A grade of", grade, "is", status)
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"golang-book/head-first-go/chapter4/keyboard"
|
||||
"headfirstgo/headfirstgo/chapter4/keyboard"
|
||||
"log"
|
||||
)
|
||||
|
||||
|
||||
17
chapter4/tocelsius/tocelsius.go~
Normal file
17
chapter4/tocelsius/tocelsius.go~
Normal file
@@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"headfirstgo/headfirstgo/chapter4/keyboard"
|
||||
"log"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Print("Enter a temperature in Farenheit: ")
|
||||
farenheit, err := keyboard.GetFloat()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
celsius := (farenheit - 32) * 5 / 9
|
||||
fmt.Printf("%0.2f degrees Celsius\n", celsius)
|
||||
}
|
||||
Reference in New Issue
Block a user