SplitN in Go

Posted by GoDoc
Public (Editable by Users)

SplitN slices s into substrings separated by sep and returns a slice of the substrings between those separators.

Go
Edit
package main

import (
	"fmt"
	"strings"
)

func main() {
	fmt.Printf("%q\n", strings.SplitN("a,b,c", ",", 2))
	z := strings.SplitN("a,b,c", ",", 0)
	fmt.Printf("%q (nil = %v)\n", z, z == nil)
}