mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 05:11:49 +08:00
fix: coding style and file format for all example.
This commit is contained in:
@@ -1,21 +1,21 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var str string = "Hi, I'm Marc, Hi."
|
||||
|
||||
fmt.Printf("The position of \"Marc\" is: ")
|
||||
fmt.Printf("%d\n", strings.Index(str, "Marc"))
|
||||
|
||||
fmt.Printf("The position of the first instance of \"Hi\" is: ")
|
||||
fmt.Printf("%d\n", strings.Index(str, "Hi"))
|
||||
fmt.Printf("The position of the last instance of \"Hi\" is: ")
|
||||
fmt.Printf("%d\n", strings.LastIndex(str, "Hi"))
|
||||
|
||||
fmt.Printf("The position of \"Burger\" is: ")
|
||||
fmt.Printf("%d\n", strings.Index(str, "Burger"))
|
||||
}
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var str string = "Hi, I'm Marc, Hi."
|
||||
|
||||
fmt.Printf("The position of \"Marc\" is: ")
|
||||
fmt.Printf("%d\n", strings.Index(str, "Marc"))
|
||||
|
||||
fmt.Printf("The position of the first instance of \"Hi\" is: ")
|
||||
fmt.Printf("%d\n", strings.Index(str, "Hi"))
|
||||
fmt.Printf("The position of the last instance of \"Hi\" is: ")
|
||||
fmt.Printf("%d\n", strings.LastIndex(str, "Hi"))
|
||||
|
||||
fmt.Printf("The position of \"Burger\" is: ")
|
||||
fmt.Printf("%d\n", strings.Index(str, "Burger"))
|
||||
}
|
||||
|
Reference in New Issue
Block a user