Friday, April 22, 2016

How to return part of a string up to specified character

How to return part of a string up to specified character

package main

import (
        "fmt"
        "strings"
)

func main() {
        str := "192.168.10.5:33069"
        fmt.Printf("%s", str[0:strings.Index(str, ":")])
}

No comments: