[Go] Split a string at a separator

Created on November 30, 2026

strings.Split returns a slice of strings separated by the delimiter you pass it. This example splits a list of place names at each comma.

package main

import(
  "fmt"
  "strings"
)

func main() {
  str := "東京,大阪,北海道"
  splittedStr := strings.Split(str, ",")
  fmt.Printf("%#v", splittedStr)
}
[]string{"東京", "大阪", "北海道"}
Go