Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

Trim function in Go

What is a string trim ?
Trim function removes a string in start and end of the string, If the string appears in other parts of the string, the string is ignored.

Example : Trim a string
package main

import (
    "fmt"
    "strings"
)

func main() {
    myString := "Audi Hello Audi world Audi"
    trimmedString := strings.Trim(myString, "Audi")
    fmt.Printf("String after trimming :%s\n", trimmedString)
}


In this example Audi is present in my string in 3 places, starting, ending and in between the string. Starting and ending occurrence of Audi is removed from myString
Output
String after trimming : Hello Audi world