📚Cheatsheets

Cheatsheet collection for go, rust, python, shell and javascript.

Replace String in Golang

Split string with number.

import (
	"fmt"
	"strings"
)

func main() {
	source := "some-data-here"
	some := strings.Replace(source, "-", " ", 1)
	fmt.Println("Hello", some) // Hello some data-here
}

Split and replace all.

import (
	"fmt"
	"strings"
)

func main() {
	source := "some-data-here"
	some := strings.ReplaceAll(source, "-", " ")
	fmt.Println("Hello", some) // Hello some data here
}