Skip to content

Latest commit

 

History

History
29 lines (21 loc) · 464 Bytes

split-strings-in-go.md

File metadata and controls

29 lines (21 loc) · 464 Bytes

Splitting strings in Go

Posted on 31 May, 2020

Splitting strings in Go is done by using the Split() method. You need to import the strings standard library to use this.

Demo

package main 

import (
	"fmt"
	"strings"
)

func main(){
	var date string = "1999-03-12"
	date_array = strings.Split(date, "-")

	fmt.Println(date_array)
}

The split() return a Go Array, running this program should print the following:

[1999 03 12]