mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 04:48:29 +08:00
fix: coding style and file format for all example.
This commit is contained in:
@@ -1,24 +1,24 @@
|
||||
// read input from the console:
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var (
|
||||
firstName, lastName, s string
|
||||
i int
|
||||
f float32
|
||||
input = "56.12 / 5212 / Go"
|
||||
format = "%f / %d / %s"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println("Please enter your full name: ")
|
||||
fmt.Scanln(&firstName, &lastName)
|
||||
// fmt.Scanf("%s %s", &firstName, &lastName)
|
||||
fmt.Printf("Hi %s %s!\n", firstName, lastName) // Hi Chris Naegels
|
||||
|
||||
fmt.Sscanf(input, format, &f, &i, &s)
|
||||
fmt.Println("From the string we read: ", f, i, s) // From the string we read: 56.12 5212 Go
|
||||
}
|
||||
// read input from the console:
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var (
|
||||
firstName, lastName, s string
|
||||
i int
|
||||
f float32
|
||||
input = "56.12 / 5212 / Go"
|
||||
format = "%f / %d / %s"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println("Please enter your full name: ")
|
||||
fmt.Scanln(&firstName, &lastName)
|
||||
// fmt.Scanf("%s %s", &firstName, &lastName)
|
||||
fmt.Printf("Hi %s %s!\n", firstName, lastName) // Hi Chris Naegels
|
||||
|
||||
fmt.Sscanf(input, format, &f, &i, &s)
|
||||
fmt.Println("From the string we read: ", f, i, s) // From the string we read: 56.12 5212 Go
|
||||
}
|
||||
|
Reference in New Issue
Block a user