1. package main
    2. import (
    3. "fmt"
    4. "strings"
    5. )
    6. func testSplit() {
    7. ips := "10.108.34.30;10.108.34.31"
    8. ipArray := strings.Split(ips,";") //以字符串里的;号为条件进行分割
    9. fmt.Printf("first ip:%s\n",ipArray[0])
    10. fmt.Printf("last ip:%s\n",ipArray[1])
    11. }
    12. func main() {
    13. testSplit()
    14. }

    输出:

    1. first ip:10.108.34.30
    2. last ip:10.108.34.31