package main import ( "strings" ) func main() { s := "234.32.12.34:4222" idx := strings.LastIndex(s, ":") ip := s[:idx] port := strings.TrimLeft(s[idx:], ":") println(ip, port) }