Splitting strings in Go

📅️ Published: May 31, 2020  • 🕣 1 min read

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


package main 

import (

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


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

[1999 03 12]
Written by Human, Not by AI

Tired of fucking up with git everyday?

ugit helps you undo git commands with ease. Undo from 20+ git scenarios

ugit cli demo screen